title: Javascript check form onsubmit
body: <p>I've used <code>event.preventDefault()</code> to stop the <code>form</code> action and call the <code>login()</code> , but when the <code>login</code> function return <code>true</code>, it still can't do the form action?</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form onsubmit="event.preventDefault();return login();" action="index.php" method="get" id="register-form" &gt;
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function login() {
  
      var password = window.prompt("Please input password", "");
      if (password !== '123') {
          alert('Password is incorrect');
          return false;
      } else {
          alert('Success');
          return true;
      }
  }
  &lt;/script&gt;
  </code></pre>