title: Prevent form submit with ajax if form fields are empty
body: <p>Im having some trouble with a simple form. I can't seem to prevent the form from submiting if the fields are empty. Is there an easy way to check if the fields are empty, and then prevent the form submitting?</p>
  
  <p>Here is my html form:</p>
  
  <pre><code>&lt;form method="post" name="simpleForm" id="simpleForm" action="handler.php"&gt;
  &lt;fieldset&gt;
      &lt;legend&gt;Info&lt;/legend&gt;
              &lt;p&gt;&lt;label for="name"&gt;Name&lt;/label&gt;&lt;br&gt;
              &lt;input id="name" name="name" class="text" /&gt;&lt;/p&gt;
              &lt;p&gt;&lt;label for="email"&gt;Email&lt;/label&gt;&lt;br&gt;
              &lt;input id="email" name="email" class="text" /&gt;&lt;/p&gt;
  
      &lt;legend&gt;Questions&lt;/legend&gt;
              &lt;p&gt;&lt;label for="qs_1"&gt;Question 1&lt;/label&gt;&lt;br&gt;
              &lt;input id="qs_1" name="qs_1" class="text" /&gt;&lt;/p&gt;
              &lt;p&gt;&lt;label for="qs_2"&gt;Question 2&lt;/label&gt;&lt;br&gt;
              &lt;input id="qs_2" name="qs_2" class="text" /&gt;&lt;/p&gt;
              &lt;p&gt;&lt;label for="qs_3"&gt;Question 3&lt;/label&gt;&lt;br&gt;
              &lt;input id="qs_3" name="qs_3" class="text" /&gt;&lt;/p&gt;
  
  &lt;/fieldset&gt;             
  
  &lt;p&gt;&lt;input type="submit" name="submit" value="Send" id="sub_btn" /&gt;&lt;/p&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here is my javascript:</p>
  
  <pre><code>$("form#simpleForm").submit(function() {
  
          var name     = $('#name').attr('value');
          var email    = $('#email').attr('value');
          var qs_1     = $('#qs_1').attr('value');
          var qs_2     = $('#qs_2').attr('value');
          var qs_3     = $('#qs_3').attr('value');
  
  
  
              $.ajax({
                  type: "POST",
                  url: "handler.php",
                  data: "name="+ name +"&amp; email="+ email +"&amp; qs_1="+ qs_1 +"&amp; qs_2="+ qs_2 +"&amp; qs_3="+ qs_3,
                  success: function(){
                      $('form#simpleForm').hide(function(){$('div.success').fadeIn();});
  
                  }
              });
          return false;
  });
  </code></pre>