title: How do I get the form submit alert to cancel form action?
body: <p>I have a javascript function that checks if someone entered their email:</p>
  
  <pre><code>function formValidate(){
  
      form1 = document.forms['_register1'];
  
      if (form1.elements['email'].value == 'Type Your Email Address Here') 
  
      {
  
          alert('Please enter your email address.');
  
          form1.elements['email'].focus();
  
          return false;
  
      }
  }
  </code></pre>
  
  <p>Here is the form html:</p>
  
  <pre><code>&lt;form method="post" enctype="multipart/form-data" name="_register1" id="_register" action="signup.php" &gt;
  &lt;input type="text" class="field" value="Type Your Email Address Here" name="email" title="Type Your Email Address Here" /&gt;
  &lt;input type="submit" class="button button-signup" value="SIGN UP!" onclick="formValidate();" /&gt; 
  </code></pre>
  
  <p>If the user has not entered an email address, I want the javascript alert to popup and once the user presses ok, I want the page to stay the same.  I don't want the action="signup.php" to happen until the email is valid.  This seems like it should be simple but I've looked all over the internet and can't find a solution.</p>
  
  <p>Thanks.</p>