Javascript script tag not working

html
workspace
javascript
nodejs

#1

I’ve been trying to link a javascript file to my html file, I’ve tried using a separate document and putting that file path as the src attribute in a script tag on my html but that didn’t work, I’ve tried putting the javascript inside the script tag on the actual html file and that hasn’t worked either. I’ve had several developers look at my code and even clone my github repo and use it but they are not reproducing the same problem and all their suggestions haven’t worked. Here is what I currently have in my html file:

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="/css/main.css">
<script type="text/javascript">
  document.addEventListener("DOMContentLoaded", function(event) { 
    window.onkeypress(function(){
        alert("working");
        if (document.getElementById("title").value()!=="" && document.getElementById("options").value!=="") {
        document.getElementById("submitchart").disabled=false;
    }
    });
    document.getElementsByClassName('main').click(function() {
        console.log("working");
    });
    });  
</script>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<p class="navbar-text"><a href="/">Voting App</a></p>
<button type="button" class="btn btn-default navbar-btn navbar-right" id="logout"><a href="/logout">Log Out <image src="/img/github.png">
</a></button>
 <ul class="nav navbar-nav navbar-right">
<li><a href="#" class="polls" id="newpoll">New Poll</a></li>
<li><a href="#" class="polls" id="mypolls">My Polls</a></li>
</ul>
</div>
</nav>
<div class="main">
    <form>
        <div class="title form-group">
    <label for="title">Title:</label>
    <input type="title" class="form-control" id="title" placeholder="Title">
    </div>
    <div class="options form-group">
      <label for="options">Options:</label>
      <input type="text" class="form-control" placeholder="Ex: cats, dogs, horses" id="options">
      </div>
      <div class="submit form-group">
      <button class="btn btn-default" type="submit" id="submitchart" disabled>Submit</button>
      </div>
    </form>
</div>
</body>
</html>

#3

window.onkeypress is not a function. You probably want to use document.addEventListener("keydown", function() {}). When you run this page in chrome you can open developer tools (F12 on windows or Cmd + Alt +J on OSX) to see the Javascript error.