title: Prevent Form from Submitting if there are Errors
body: <p>Before I get into the problem details, I still need to tell you about this form I am creating. I have a Registration form and once the user submits the form by clicking the Submit button, it will NOT go directly to a Successfully Registered page. The user will be seeing a Confirmation page prior to that. In this page, the user will see all the data he inputted for him to review. Below it are the Confirm button and the Return button (if user still likes/needs to edit his details, it will then show the form for him to edit once this button is clicked). But here's the thing, the Registration form page and the Confirmation page are in just the same page. What I did is that when the user submits the form, it will hide some elements including the Submit button and then just show the details he inputted. When the user clicks the Return button on the Confirmation page, it will just then show again the hidden fields so the user can edit his details.</p>
  
  <p>What I did in preventing the form from submitting when there are errors is that I disabled the submit button. But it is not working. I am using bootstrap for my form so when there are errors, the input fields' borders would turn red and would obtain a class <code>has-error</code>. Here's what I did:</p>
  
  <pre><code>$("td .form-group").each(function() {
      if($(this).hasClass('has-error') == true) {
          $('#submit').attr('disabled', false);
      } else { 
          $('#submit').attr('disabled',true);
      }
  });
  </code></pre>
  
  <p>But again, it is not working. I also googled some jQueries like the <code>.valid()</code> and <code>.validate()</code> functions but I'm not really sure about it and also didn't work for me.</p>
  
  <p>I also did this code where the Submit button should disable when required fields are still empty. And it is perfectly working:</p>
  
  <pre><code>$('#submit').attr('disabled',true);
  $('input[id^="account"]').keyup(function() {
      if(($('#profile-company_name').val().length !=0) &amp;&amp; ($('#account-mail_address').val().length !=0) &amp;&amp; ($('#account-confirmemail').val().length !=0) &amp;&amp; ($('#account-login_name').val().length !=0) &amp;&amp; (($('#account-password').val().length !=0)) &amp;&amp; ($('#account-confirmpassword').val().length !=0)) {
          $('#submit').attr('disabled', false);
      } else {
          $('#submit').attr('disabled',true);
      }
  });
  </code></pre>
  
  <p>I hope you understand my problem. I will make it clearer if this confuses you.</p>