Core: Validation fails to trigger when next field is already filled out

This change fix the bug when used with remote rule, it's already fixed
with other rules in commit 737630e788

Ref #1508
This commit is contained in:
Brahim Arkni
2016-01-18 15:25:23 +00:00
parent 40dae365ed
commit 7d74fc4157
3 changed files with 106 additions and 34 deletions

View File

@@ -289,7 +289,7 @@ $.extend( $.validator, {
if ( event.which === 9 && this.elementValue( element ) === "" || $.inArray( event.keyCode, excludedKeys ) !== -1 ) {
return;
} else if ( element.name in this.submitted || this.isValidElement( element ) ) {
} else if ( element.name in this.submitted || element.name in this.invalid ) {
this.element( element );
}
},
@@ -487,6 +487,7 @@ $.extend( $.validator, {
if ( $.fn.resetForm ) {
$( this.currentForm ).resetForm();
}
this.invalid = {};
this.submitted = {};
this.prepareForm();
this.hideErrors();
@@ -539,18 +540,6 @@ $.extend( $.validator, {
return this.size() === 0;
},
// Check if the given element is valid
// return
// true If the field is valid
// false If the field is invalid
// undefined If the field is not validated yet.
//
// Note that this method assumes that you have
// already called `validate()` on your form
isValidElement: function( element ) {
return this.invalid[ element.name ] === undefined ? undefined : !this.invalid[ element.name ];
},
size: function() {
return this.errorList.length;
},
@@ -1431,7 +1420,7 @@ $.extend( $.validator, {
validator.prepareElement( element );
validator.formSubmitted = submitted;
validator.successList.push( element );
delete validator.invalid[ element.name ];
validator.invalid[ element.name ] = false;
validator.showErrors();
} else {
errors = {};