Skip to content

Commit

Permalink
If the error message for a field starts with an !, use it (without th…
Browse files Browse the repository at this point in the history
…e !) instead of the result

from the remote call.
  • Loading branch information
Eduardo Arino de la Rubia committed Nov 12, 2012
1 parent f221f68 commit ed6b96e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion jquery.validate.js
Expand Up @@ -1044,7 +1044,13 @@ $.extend($.validator, {
validator.showErrors();
} else {
var errors = {};
var message = response || validator.defaultMessage( element, "remote" );
var defaultMessage = validator.defaultMessage( element, "remote" );

if (/^!/.match(defaultMessage)) {
response = defaultMessage.replace(/^!/, "")
}

var message = response || defaultMessage;
errors[element.name] = previous.message = $.isFunction(message) ? message(value) : message;
validator.invalid[element.name] = true;
validator.showErrors(errors);
Expand Down

0 comments on commit ed6b96e

Please sign in to comment.