$("#addSkuForm").validate({ // Specify validation rules rules: { // The key name on the left side is the name attribute // of an input field. Validation rules are defined // on the right side sku_model: "required", n_c: { required: true, minlength: 12, number: true, maxlength: 12, remote: { url: "/cost-price/n-c", type: "GET", data: { t_n_c: function(){ return $('#n_c').val(); } } } // Specify that email should be validated // by the built-in "email" rule }, product_description: { required: true // Specify that email should be validated // by the built-in "email" rule }, rcp: { required: true, min: 0 }, cost_price: { required: true, min: 0 }, sub_category: { required: true }, margin: { required: true }, subsidy: { required: true } }, // Specify validation error messages messages: { sku_model: "Please enter sku model", n_c: { required: "Please enter the 12NC", remote : "12NC already exist" }, product_description: { required: "Please provide product description" }, rcp: { required : "Please enter RCP", number : true, min: "Value must be greater than 0" }, cost_price: { required : "Please enter Cost Price", number : true, min: "Value must be greater than 0" }, sub_category: "Please select sub category" /*margin: { required : "Please enter Margin", number : true },*/ /*subsidy: { required : "Please enter Subsidy", number : true }*/ }, // Make sure the form is submitted to the destination defined // in the "action" attribute of the form when valid submitHandler: function(form) { /*form.submit();*/ WRITE THE AJAX CALL HERE } });
For remote method, Just call the post call and get the true or false in string format.