title: repeat checking of form data without submit (JavaScript, HTML, JQuery)
body: <p>I'm trying to submit a HTML form, only when all the fields do not return false in the Javascript code.</p>
  
  <p>My HTML looks like this, for simplicity I have just kept the name and email</p>
  
  <pre><code>    &lt;form method="post" action="RegistrationServlet" class="iform" 
             onsubmit="return sendForm();"&gt;
  
      &lt;ul&gt;&lt;li&gt;&lt;label for="YourName"&gt;*Your Name &lt;span id="regNameErr"&gt;&lt;/span&gt;&lt;/label&gt;
      &lt;input class="itext" type="text" name="YourName" id="YourName" /&gt;&lt;/li&gt;
  
      &lt;li&gt;&lt;br /&gt;&lt;label for="YourEmail"&gt;*Your Email &lt;span id="regEmailErr"&gt;&lt;/span&gt;&lt;/label&gt;  
      &lt;input class="itext" type="text" name="YourEmail" id="YourEmail" /&gt;&lt;/li&gt;
  
      &lt;li&gt;&lt;input type="submit" value="Submit" class="ibutton" name="SendaMessage"   
        id="SendaMessage" value="Send a Message!" readonly="readonly" /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/form&gt;
  </code></pre>
  
  <p>The Javascript looks like this, again for simplicity I am just checking 2 fields:</p>
  
  <pre><code>    &lt;script type="text/javascript" 
             src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
      window.sendForm = function() {
               if (($("#YourName").val() == "") || ($("#YourName").val().length &gt; 55)) {
                                      $("#YourName").addClass("required");
                                      window.scroll(0, 190);
                                      $("#regNameErr").text("required");
                                      return false;
                                  }
                                  if ($("#YourEmail").val() == "") {
                                      $("#YourEmail").addClass("required");
                                      window.scroll(0, 190);
                                      $("#regEmailErr").text("required");
                                      return false;
                                  }
  
                                  if (!isEmailValid($("#YourEmail").val())) {
                                      $("#YourEmail").addClass("required");
                                      window.scroll(0, 190);
                                      $("#regEmailErr").text("required");
                                      return false;
                                  }  
                                  $("#SendaMessage").val("Please Wait...");
                                  return true;
                              }
  </code></pre>
  
  <p>Why is the sendForm() function not repeatedly being called to check that all fields are correct before submitting.  Any ideas?</p>
  
  <p>Also I understand that I can add a bounty after 2 days but I am not seeing any button on the editor.</p>
  
  <p>Can you help?</p>