Core: core.js, methods.js, Fix for #1567 - jquery-validation ignores data obj when validating, incorrectly returning previous status

This change determines if either the validated element's value OR one of the data properties has changed before aborting the remote request. If your remote validation is skipped due to being dependent on the value of another field, this fixes that issue.
This commit is contained in:
Christopher Bauer
2015-09-03 16:42:05 -04:00
parent 6129ab613e
commit 17a56baa6f
2 changed files with 40 additions and 4 deletions

View File

@@ -1291,7 +1291,7 @@ $.extend( $.validator, {
}
var previous = this.previousValue( element ),
validator, data;
validator, data, optionDataString;
if (!this.settings.messages[ element.name ] ) {
this.settings.messages[ element.name ] = {};
@@ -1300,12 +1300,12 @@ $.extend( $.validator, {
this.settings.messages[ element.name ].remote = previous.message;
param = typeof param === "string" && { url: param } || param;
if ( previous.old === value ) {
optionDataString = $.param( $.extend( { data: value }, param.data ) );
if (previous.old === optionDataString) {
return previous.valid;
}
previous.old = value;
previous.old = optionDataString;
validator = this;
this.startRequest( element );
data = {};