title: e.preventDefault(); not stopping form submission
body: <p>I'm working on a simple form validation script, that just checks fields aren't empty to begin with (further advanced validation will be added later).</p>
  
  <p>However, on submission, the form seems to continue to submit, even though I am using <code>preventDefault()</code>. Could someone check my syntax and my logic for me please, figure out what's going wrong? I get a flash of the validation before the form submits as normal.</p>
  
  <p>Fiddle: <a href="http://jsfiddle.net/qb9KS/1/" rel="nofollow">http://jsfiddle.net/qb9KS/1/</a></p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;form id="userForm" method="POST" action="form-process.php"&gt;
      &lt;div&gt;
          &lt;fieldset&gt;
              &lt;legend&gt;User Information&lt;/legend&gt;
  
              &lt;div id="errorDiv"&gt;&lt;/div&gt;
  
              &lt;label for="name"&gt;Name:*&lt;/label&gt;
              &lt;input type="text" id="name" name="name" /&gt;
              &lt;span class="errorFeedback errorSpan" id="nameError"&gt;Name is required&lt;/span&gt;
  
              &lt;br /&gt;
  
              &lt;label for="city"&gt;City:&lt;/label&gt;
              &lt;input type="text" id="city" name="city" /&gt;
  
              &lt;br /&gt;
  
              &lt;label for="state"&gt;State:&lt;/label&gt;
              &lt;select id="state" name="state"&gt;
                  &lt;option&gt;&lt;/option&gt;
                  &lt;option&gt;Alabama&lt;/option&gt;
                  &lt;option&gt;California&lt;/option&gt;
                  &lt;option&gt;Colorado&lt;/option&gt;
                  &lt;option&gt;Florida&lt;/option&gt;
                  &lt;option&gt;Illinois&lt;/option&gt;
                  &lt;option&gt;New Jersey&lt;/option&gt;
                  &lt;option&gt;New York&lt;/option&gt;
                  &lt;option&gt;Wisconsin&lt;/option&gt;
              &lt;/select&gt;
  
              &lt;br /&gt;
  
              &lt;label for="zip"&gt;ZIP:&lt;/label&gt;
              &lt;input type="text" id="zip" name="zip" /&gt;
  
              &lt;br /&gt;
  
              &lt;label foe="email"&gt;Email Address:*&lt;/label&gt;
              &lt;input type="text" id="email" name="email" /&gt;
              &lt;span class="errorFeedback errorSpan" id="emailError"&gt;Email is required&lt;/span&gt;
  
              &lt;br /&gt;
  
              &lt;label for="phone"&gt;Telephone Number:&lt;/label&gt;
              &lt;input type="text" id="phone" name="phone" /&gt;
              &lt;span class="errorFeedback errorSpan" id="phoneError"&gt;Format: xxx-xxx-xxxx&lt;/span&gt;
  
              &lt;br /&gt;
  
              &lt;label for="work"&gt;Number Type:&lt;/label&gt;
              &lt;input class="radioButton" type="radio" name="phoneType" id="work" value="work" /&gt;
              &lt;label class="radioButton" for="work"&gt;Work&lt;/label&gt;
              &lt;input class="radioButton" type="radio" name="phoneType" id="home" value="home" /&gt;
              &lt;label class="radioButton" for="home"&gt;Home&lt;/label&gt;
              &lt;span class="errorFeedback errorSpan" id="phonetypeError"&gt;Please choose an option&lt;/span&gt;
  
              &lt;br /&gt;
  
              &lt;label for="password1"&gt;Password:*&lt;/label&gt;
              &lt;input type="password" id="password1" name="password1" /&gt;
              &lt;span class="errorFeedback errorSpan" id="password1Error"&gt;Password required&lt;/span&gt;
  
              &lt;br /&gt;
  
              &lt;label for="password2"&gt;Verify Password:*&lt;/label&gt;
              &lt;input type="password" id="password2" name="password2" /&gt;
              &lt;span class="errorFeedback errorSpan" id="password2Error"&gt;Passwords don't match&lt;/span&gt;
  
              &lt;br /&gt;
  
              &lt;input type="submit" id="submit" name="submit"&gt;
          &lt;/fieldset&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code>$(document).ready(function() {
  $("#userForm").submit(function(e) {
      removeFeedback();
      var errors = validateForm();
      if (errors == "") {
          return true;
      }
      else {
          provideFeedback(errors);
          e.preventDefault();
          return false;
      }
  });
  
  function validateForm() {
      var errorFields = new Array();
      if ($('#name').val() == "") {
          errorFields.push('name');
      }
      if ($('#email').val() == "") {
          errorFields.push('email');
      }
      if ($('#password1').val() == "") {
          errorFields.push('password1');
      }
      return errorFields;
  }
  
  function provideFeedback(incomingErrors) {
      for (var i = 0; i &lt; incomingErrors.length; i++) {
          $("#" + incomingErrors[i]).addClass("errorClass");
          $("#" + incomingErrors[i] + "Error").removeclass("errorFeedback");
      }
      $("#errorDiv").html("Errors encountered");
  }
  
  function removeFeedback() {
      $("#errorDiv").html("");
      $('input').each(function() {
          $(this).removeClass("errorClass");
      });
      $('.errorSpan').each(function() {
          $(this).addClass("errorFeedback");
      });
  }
  });
  </code></pre>