Skip to content

Commit

Permalink
Fixed validation for name array within form.
Browse files Browse the repository at this point in the history
If a form input has a name="xyz[]" then only first element with name="xyz[]" is validated and rest are ignored.
  • Loading branch information
Saurabh-Sharma committed Dec 8, 2016
1 parent c1db10a commit 7d10838
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/core.js
Expand Up @@ -428,8 +428,15 @@ $.extend( $.validator, {

checkForm: function() {
this.prepareForm();
for ( var i = 0, elements = ( this.currentElements = this.elements() ); elements[ i ]; i++ ) {
this.check( elements[ i ] );
for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) {
//Fix validation for name array within form
if (this.findByName( elements[i].name ).length != undefined && this.findByName( elements[i].name ).length > 1) {
for (var cnt = 0; cnt < this.findByName( elements[i].name ).length; cnt++) {
this.check( this.findByName( elements[i].name )[cnt] );
}
} else {
this.check( elements[i] );
}
}
return this.valid();
},
Expand Down

0 comments on commit 7d10838

Please sign in to comment.