mirror of
https://github.com/jquery-validation/jquery-validation.git
synced 2025-12-14 20:35:47 +01:00
Core: Focus invalid element when validating a custom set of inputs
Invalid element is not focused when validate a custom set of inputs and the last one is a valid input. The issue is element method, via prepareElement method, via reset method, resets errorList state after validate each input so the global state of the validator is not preserved. Closes #1327
This commit is contained in:
@@ -90,16 +90,19 @@ $.extend($.fn, {
|
||||
},
|
||||
// http://jqueryvalidation.org/valid/
|
||||
valid: function() {
|
||||
var valid, validator;
|
||||
var valid, validator, errorList;
|
||||
|
||||
if ( $( this[ 0 ] ).is( "form" ) ) {
|
||||
valid = this.validate().form();
|
||||
} else {
|
||||
errorList = [];
|
||||
valid = true;
|
||||
validator = $( this[ 0 ].form ).validate();
|
||||
this.each( function() {
|
||||
valid = validator.element( this ) && valid;
|
||||
errorList = errorList.concat( validator.errorList );
|
||||
});
|
||||
validator.errorList = errorList;
|
||||
}
|
||||
return valid;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user