title: Server side validation using JQuery validator (Cakephp)
body: <p>Hi i am currently doing a school project using cakePHP. I have the following form and assume that the form tag is created.</p>
  
  <pre><code>&lt;?php echo $form-&gt;input('number',array('id'=&gt;"number",'title'=&gt;"Please enter a number with at least 3 and max 15 characters ha!"));?&gt;
  
  &lt;?php echo $form-&gt;input('secret',array('id'=&gt;"secret"));?&gt;
  
  &lt;?php echo $form-&gt;input('math',array('id'=&gt;"math",'title'=&gt;"Please enter the correct result!"));?&gt;
  
   &lt;?php echo $form-&gt;input('userName',array('id'=&gt;"userName",'title'=&gt;"User Exist"));?&gt;
  </code></pre>
  
  <p>I am using a client side validation and here is the code that:</p>
  
  <pre><code>$.validator.addMethod("buga", function(value) {
      return value == "buga";
  }, 'Please enter "buga"!');
  
  // this one requires the value to be the same as the first parameter
  $.validator.methods.equal = function(value, element, param) {
      return value == param;
  };
  
      $().ready(function() {
      var validator = $("#texttests").bind("invalid-form.validate", function() {
          $("#summary").html("Your form contains " + validator.numberOfInvalids() + " errors, see details below.");
      }).validate({
          debug: true,
          errorElement: "em",
          errorContainer: $("#warning, #summary"),
          errorPlacement: function(error, element) {
              error.appendTo( element.parent("td").next("td") );
          },
          success: function(label) {
              label.text("ok!").addClass("success");
          },
          rules: {
              "data[User][number]": {
                  required:true,
                  minlength:3,
                  maxlength:15,
                  number:true 
              },
              "data[User][secret]": "buga",
              "data[User][math]": {
                  equal: 11   
              }
          },
                      submitHandler: function(form) {
                          form.submit();
                      }
  
  
      });
  
  });
  </code></pre>
  
  <p>The above only does client side validation can do for the first three inputs but my last input for this case may require to check the username is unique. How am i able to do the ajax call to the server? I am just confused in that part. Hope someone can guide me.</p>