title: Maximum call stack size exceeded with jQuery promise()
body: <p>I'm trying to apply a simple form validation in jQuery. If a form field is empty, add a class <code>error</code>. If any of the fields are empty, don't submit. I have the following:</p>
  
  <pre><code>$('#contact-form').submit(function(event) {
      event.preventDefault();
  
      var formValid = true;
      $('input.required, textarea.required, select.required').each(function() {
          if($(this).val() === '') {
              formValid = false;
              $(this).addClass('error');
          } else {
              $(this).removeClass('error');
          }
      }).promise().done(function() {
          if(formValid) {
              $('#contact-form').submit();
          }
      });
  });
  </code></pre>
  
  <p>Howerver when the code hits the line to submit the form, I am seeing a JavaScript error:</p>
  
  <p><strong>Uncaught RangeError: Maximum call stack size exceeded</strong></p>