title: onSubmit button won't load location
body: <p>I switched from <code>type=click</code> to <code>type=submit</code> so that I can use the Enter key to login. The if/else statements for invalid username/password functions fine. But if I input the correct credentials it wont load the location(different HTML page.)</p>
  
  <p>PS: I'm new to coding in general(only 3 weeks in) Try to explain it so a newbie would know.
  Thanks in advance.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function check_info(){
          var username = document.login.username.value;
          var password = document.login.password.value;
  
          if (username=="" || password=="") {
              alert("Please fill in all fields")
          } else {
              if(username=="test") {
                  if (password=="test") {
                      location="Random.html"
                  } else {
                      alert("Invalid Password")
                  }
              } else { 
                  alert("Invalid Username")
              }
          }
      }
  &lt;/script&gt;
  
  &lt;form name=login onsubmit="check_info()"&gt;
      Username:
      &lt;input type="text" name="username" id="username"/&gt;
      &lt;br&gt;
      Password:
      &lt;input type="password" name="password" id="password"/&gt;
      &lt;br&gt;
      &lt;br&gt;
      &lt;input type="submit" value="Login"/&gt;
  &lt;/form&gt;
  </code></pre>