title: Given a form submit, how to only submit if the server first responses back with a valid flag?
body: <p>I have a form, with a text input and a submit button. </p>
  
  <p>On submit, I want to hit the server first to see if the input is valid, then based on the response either show an error message or if valid, continue with the form submit.</p>
  
  <p>Here is what I have:</p>
  
  <pre><code>$('#new_user').submit(function(e) { 
      $.ajax({
          type: "POST",
          dataType: 'json',
          url: "/users/stuff",
          data: $('#new_user').serialize(),
          success: function(data){
              if (data.valid) {
                  return true
              } else {
                  // Show error message
                  return false;
                  e.preventDefault();
              }
          }
      });
  });
  </code></pre>
  
  <p>Problem is the form is always submitting, given the use case, what's the right way to implement? Thanks</p>