title: my onsubmit="return onNewUserRegistrationCheck(this);" still submits form on FALSE
body: <p>I've read several SO posts on this issue and the one I found with a <em>possible</em> explanation was <a href="https://stackoverflow.com/questions/2543963/onsubmit-returning-false-is-not-working">this</a> one.
  A response in that post says "Browsers do not call the onSubmit event on the form if you call submit() programmatically."</p>
  
  <p>I'm not sure if this is the operative thing affecting my form.  </p>
  
  <p>My code onsubmit="return onNewUserRegistrationCheck(this);" is 100% working 
  -- the call to onNewUserRegistrationCheck(this)  is 100% occurring.</p>
  
  <p>Here's that code:</p>
  
  <pre><code>      function onNewUserRegistrationCheck(theForm)
        {
  
            alert("In onNewUserRegistrationCheck()");
  
            if(theForm.loginname.value == "&lt;?php echo Labels::$DEFAULTLOGINEMAILLABEL ?&gt;" 
                || theForm.password.value == "&lt;?php echo Labels::$DEFAULTPASSWORDLABEL ?&gt;" )
            {  
                alert("returning false now, so -- HOPEFULLY the form doesn't submit");
                return false;
            }
       }
  </code></pre>
  
  <p>Here's the form:</p>
  
  <pre><code>    &lt;form enctype="multipart/form-data" onsubmit="return onNewUserRegistrationCheck(this);"
                   class="registerFormStyles" name="registerForm" id="regform"
                   action="regTheNewUser.php" method="post"&gt;
           &lt;input type="text" id="loginname" name="&lt;?php  echo Labels::$USERNAMELABEL ?&gt;"
                 style="width:260px" value="&lt;?php echo Labels::$DEFAULTLOGINEMAILLABEL ?&gt;" /&gt;
  
           &lt;input type="password" placeholder="&lt;?php echo Labels::$DEFAULTPASSWORDLABEL ?&gt;" 
                    id="password" name="&lt;?php echo Labels::$PASSWORD ?&gt;"
              style="width:220px" class="inactive" /&gt;
  
           &lt;input type="hidden" name="newUserRegister" id="newUserRegisterId"&gt;
  
           &lt;input type="image" name="registerButton" value="Register" class="login-button-landing" 
                      onclick="document.registerForm.submit();"&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>Notice I use a type="image" and do a programmatic submit().  According to some SO posts, the result of
  a programmatic submit() like I'm doing is this:  <strong>'Browsers do not call the onSubmit event on the form if you call submit() programmatically'</strong></p>
  
  <p>However I'm seeing 2 alert boxes when I click on my name="registerButton" pseudo-submit button:</p>
  
  <pre><code>  alert box #1 pops up and says:  "In onNewUserRegistrationCheck()"
  </code></pre>
  
  <p>then....</p>
  
  <pre><code>  alert box #2 pops up and says:  "returning false now, so -- HOPEFULLY the form doesn't submit"
  </code></pre>
  
  <p>Those 2 alert boxes appear when I click my name="registerButton"  button on the form.
  So I must (?) misunderstand what is meant in the posts I've read that say 
  'calling submit() doesn't fire the onsubmit event'.</p>
  
  <p>The bottom line is the form is still submitted to the file "regTheNewUser.php"
  even though you can see that 'return false' occurred because of the alert message
  being seen <strong>"returning false now, so -- HOPEFULLY the form doesn't submit"</strong></p>
  
  <p>How can I stop the form being submitted <em>without</em> using a type="submit" button?
  I've proved to myself that my <strong>onsubmit="return onNewUserRegistrationCheck(this);"</strong>
  is 100% being called.  I return false but the form is submitted anyway.</p>
  
  <p>How can I stop the form being submitted when I find invalid form text entry
  and why doesn't 'return false' above STOP my form submission?</p>