title: Remote Validation in jQuery not validating
body: <p>This form will INSERT both an email and password into my MYSQL db </p>
  
  <p>First, I am trying to validate an email remotely to make sure it does not exists, and also that
  the Pswd and Pswd2 are equal.</p>
  
  <p>the script writes to the db, but the validation is not working. I am new to JQ and Ajax so any help would be apprecated.
  Thanks.</p>
  
  <p>FORM: </p>
  
  <pre><code>    &lt;link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" /&gt;
      &lt;script src="http://code.jquery.com/jquery-1.6.4.min.js"&gt;&lt;/script&gt;
      &lt;script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"&gt;&lt;/script&gt;
      &lt;script src="jquery.validate.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/additional-methods.min.js"&gt;&lt;/script&gt;
  
     ... 
          &lt;div data-role="content"&gt;
               &lt;form  id="AddUser" class="ui-body ui-body-a ui-corner-all" data-ajax="true" &gt;
                      &lt;fieldset&gt;
                          &lt;div data-role="fieldcontain"&gt;
                              &lt;label for="Email"&gt;Email Address:&lt;/label&gt;
                              &lt;input id="Email" type="email" /&gt;
                          &lt;label for="Pswd"&gt;Password:&lt;/label&gt;
                              &lt;input id="Pswd" type="password" /&gt; 
                          &lt;label for="Pswd2"&gt;Confirm Password:&lt;/label&gt;
                              &lt;input id="Pswd2" type="password" /&gt;    
                          &lt;/div&gt;
                          &lt;button type="submit" id="submit" data-theme="b" name="submit" value="submit-value"&gt;Submit&lt;/button&gt;
                      &lt;/fieldset&gt;
          &lt;/form&gt;     
          &lt;/div&gt;
  
  ...
  </code></pre>
  
  <p>below is the js inside the document:</p>
  
  <pre><code> &lt;script&gt;
      $(document).ready(function() { 
  
          var validator = 
          $('#AddUser').validate({ 
              rules: { 
                  Pswd: { 
                      required: true, 
                  }, 
                  Pswd2: { 
                      required: true, 
                      equalTo: "#Pswd" 
                  }, 
                  Email: { 
                     required: true, 
                     email: true, 
                     remote: "process/ValidateEmail.php" 
                  }
              }, 
              messages: { 
                  Pswd: { 
                      required: "Provide a password", 
                  }, 
                  Pswd2: { 
                      required: "Repeat your password", 
                      equalTo: "Enter the same password as above" 
                  }, 
                  Email: { 
                      required: "Not A Valid Email Address", 
                      remote: "already in use"
                  }
               }
          }); // end var validator
  
              if (validator)
              {
                  $("#AddUser").submit(function(){        
                  //make Variables
                  var emailVar =$('input[id=Email]').val();
                  var pswdVar = $('input[id=Pswd]').val();
                  var pswdconfirm = $('input[id=Pswd2]').val();
                  var querystring = "Email="+emailVar+"&amp;Pswd="+pswdVar;
  
                  $.post("process/AddUser.php",querystring);
  
              }); //end submit()
              }; // end if validator
  
  
      }); //end ready()
  
      &lt;/script&gt;
  </code></pre>
  
  <p>the Validator file (ValidateEmail.php)</p>
  
  <pre><code>&lt;?php 
  
      $UserEmail = $_POST["Email"];
  
      include "connection.php";
  
      $sqlEmail= mysql_query("Select EmailAddress from USERS where EmailAddress='$UserEmail'"); 
      $EmailCheck=mysql_fetch_array($sqlEmail);
  
      if (mysql_num_rows($EmailCheck) &gt; 0) {
          echo json_encode(true);
      } else {
          echo json_encode(false);
      }
  
  ?&gt;
  </code></pre>