title: Ajax callback not executing
body: <p>I have a form page that I intend submitting using Ajax. My plan is to
      1. Check if email already exists using Ajax
      2. Check if passwords match
      3. If it does, switch to another "screen" and
      4. Submit the form using Ajax</p>
  
  <p>I'm confused because the validate function does not run. It neither switches screens not alerts when passwords do not match. As such, the form does not get submitted either. My code goes below</p>
  
  <pre><code>$('form input:last-child').click(function(e){
      e.preventDefault();
      var allFields = e.target.parentNode;
  
      function validate () {
          if (allFields.elements[3].value !== allFields.elements[4].value) {
              return false; // If they don't match, return false
          } else {
              $('#form-div form').css('left', '-70%');
              $('#confirm p').css('margin-left', '-12%'); // else switch screens
          }
      }
      if (validate != false) {
          $('#hidden').load("server_script.php"); // `hidden` is a hidden div somewhere on the page
      } else 
          alert ("Passwords do not match");
  });
  </code></pre>
  
  <p>I'm thinking, if they don't match, the rest of the event listener won't run since the false terminates the function from that point on. So I tried making an instance of the validate function outside the event listener and calling it inside the click function but it won't parse because of dependency variables so I'm not sure how to go about this.</p>
  
  <p><strong>UPDATE</strong>
  Associated HTML attached. (Bonus: the regex pattern does not match 2 or more letters)</p>
  
  <pre><code>&lt;div id=form-div&gt;
  &lt;form method=POST action="" &gt;
  First Name: &lt;br&gt; &lt;input type=text name=first_name pattern="[a-z]{2,}" required /&gt; &lt;br&gt; &lt;br&gt;
  Last Name: &lt;br&gt; &lt;input type=text name=last_name pattern="[a-z]{2,}" required /&gt; &lt;br&gt; &lt;br&gt;
  Email: &lt;span id=emailReport&gt;&lt;/span&gt; &lt;br&gt; &lt;input type=email name=email id=email required /&gt; &lt;br&gt; &lt;br&gt;
  Password: &lt;br&gt; &lt;input type=password name=password required pattern=".{6,}" title="Password must be six or more characters" /&gt; &lt;br&gt; &lt;br&gt;
  Confirm password: &lt;br&gt; &lt;input type=password name=password required /&gt; &lt;br&gt; &lt;br&gt;
  &lt;input type=hidden name=sign_up_date /&gt;
  &lt;input type=submit value='sign up' /&gt;
  &lt;/form&gt;
  
  &lt;div id=confirm&gt; &lt;p&gt;Some text&lt;/p&gt; &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>