I am using jQuery Validate Plugin found from below URL
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
I just wanted to make a validation rule to check if the record exists in database or not. I also made ajax script like blow & added it using $.validator.addMethod but it is not working. can someone please suggest how to do this ?
$.validator.addMethod("check_exists", function(value) {
$.ajax({
type: "POST",
url: "xyz.com/check_exists.php",
data: $( "#frmEdit" ).serialize(),
success: function(result){
if(result=="exists")
return false;
else
return true;
},
});
}, 'This record is already exists');
Validation plugin has a built in
remoteoption you provide a url to and the request will be made to server from within plugin. For what you are doing there is no need to creat a whole new methodhttp://docs.jquery.com/Plugins/Validation/Methods/remote#options