title: javascript confirm cancel still submits form
body: <p>I have the following sequence on a form page, first it runs through the captcha then it validates the email address and then asks if you are sure you want to unsubscribe.</p>
  
  <p>Everything works perfectly except that clicking "Cancel" still submits the form.  I can't use "onclick" in the submit button because it will bypass the captcha code.  In my "if the email is true 'else'" statement I've tried both "return" and "return:false" but neither of them stop the form submission.</p>
  
  <p>Thanks for your help.</p>
  
  <pre><code>&lt;form action='&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;' name="unsubscribe" method='post' onsubmit="return checkForm(this);""&gt;
  
  function checkForm(form) { 
  var frm = document.unsubscribe;
   if(!form.captcha.value.match(/^\d{5}$/)) {
        alert('Please enter the CAPTCHA digits in the box provided'); 
          form.captcha.focus();           
          return false;
          }   
          if (validEmail(frm.Email.value) != true) {
                  alert("Please enter a valid email address");
                  frm.Email.focus();
                  return false;
          }   
          if (validEmail(frm.Email.value) == true) {
                  confirm('Are you sure you want to unsubscribe?');  
                  return true;
          }
          else {          
              return false;   
      }
  }   
  
  function validEmail(email){
      var status = false; 
      var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
      if (email.search(emailRegEx) == -1) {
      status = false;
  }
      else {
      status = true;
  }
      return status;  
  }   
  </code></pre>