Skip to content

Instantly share code, notes, and snippets.

@jagregory
Created December 7, 2010 17:04
Show Gist options
  • Save jagregory/732067 to your computer and use it in GitHub Desktop.
Save jagregory/732067 to your computer and use it in GitHub Desktop.
Custom ajax "unique" validator with reason in response
var validator = $('form').validate({
rules: {
number: {
remote: {
url: 'UniqueNumber',
dataType: 'json',
success: function(data) {
if (data.unique == true) {
return;
}
validator.showErrors({ number: 'Not unique because of ' + data.reason });
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment