title: Javascript form validation return false error
body: <p>I'm trying to do a form and while the alert is popping up it is still submitting. How do I get it to stop submitting??</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function validate() {
    var first = document.register.first.value;
    if (first == "") {
      alert("please enter your name");
      first.focus();
      return false;
    }
    return (true);
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;body&gt;
    &lt;form name="register" action="testform.php" onsubmit="return(validate());"&gt;
      &lt;input type="text" name="first" /&gt;
      &lt;button type="submit" /&gt;Submit
    &lt;/form&gt;
  &lt;/body&gt;</code></pre>
  </div>
  </div>
  </p>