Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Add capability to check array of inputs #2431

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/core.js
Expand Up @@ -454,7 +454,16 @@ $.extend( $.validator, {
checkForm: function() {
this.prepareForm();
for ( var i = 0, elements = ( this.currentElements = this.elements() ); elements[ i ]; i++ ) {
this.check( elements[ i ] );
var toBeChecked = this.findByName( elements[ i ].name );

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to replace that line by:

Suggested change
var toBeChecked = this.findByName( elements[ i ].name );
var toBeChecked = this.findByName( elements[ i ].name ).not( this.settings.ignore );


//Fix validation for name array within form
if ( toBeChecked.length > 1 && toBeChecked.attr( "type" ) !== "checkbox" && toBeChecked.attr( "type" ) !== "radio" ) {
for ( var cnt = 0; cnt < toBeChecked.length; cnt++ ) {
this.check( toBeChecked[ cnt ] );
}
} else {
this.check( elements[ i ] );
}
}
return this.valid();
},
Expand Down
2 changes: 1 addition & 1 deletion test/rules.js
Expand Up @@ -49,7 +49,7 @@ QUnit.test( "rules() - external", function( assert ) {
} );

QUnit.test( "rules() - external - complete form", function( assert ) {
assert.expect( 1 );
assert.expect( 2 );

var methods = $.extend( {}, $.validator.methods ),
messages = $.extend( {}, $.validator.messages ),
Expand Down