Created
December 7, 2010 17:04
-
-
Save jagregory/732067 to your computer and use it in GitHub Desktop.
Custom ajax "unique" validator with reason in response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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