title: Check register form without redirecting?
body: <p>I'm working with passport to register users. Before they register the user also must answer a few questions which save to their profile. The answered are stored in Vars. </p>
  
  <p>My problem is if the user has an issue while submitting the form (example: the user name is taken) The page redirects back and the data from the questions is lost. How would I go about checking to make sure the form is good before redirecting anywhere? </p>
  
  <p>I tried this but so far I cant get it to do what I need it to do: </p>
  
  <pre><code>   $(function() {
                  $("#checkForm").on("submit", function(e) {
                      e.preventDefault();
                      $.ajax({
                          url: $(this).attr("action"),
                          type: 'POST',
                          data: $(this).serialize(),
                          beforeSend: function() {
                              alert('do something to check form?')
                          },
                          success: function(data) {
                              alert('Form is good now register user?')
                              $("#message").hide();
                              $("#response").html(data);
                          }
                      });
                  });
              }); 
  </code></pre>