Content-Length: 1301 | pFad | http://github.com/jquery-validation/jquery-validation/pull/2498.diff

thub.com diff --git a/src/core.js b/src/core.js index 240e2737b..6ebbf9c11 100644 --- a/src/core.js +++ b/src/core.js @@ -453,9 +453,22 @@ $.extend( $.validator, { }, checkForm: function() { + var checkedCache = {}; + this.prepareForm(); for ( var i = 0, elements = ( this.currentElements = this.elements() ); elements[ i ]; i++ ) { - this.check( elements[ i ] ); + var element = elements.eq(i); + + var type = element.attr( "type" ); + if ( type === 'checkbox' || type === 'radio' ) { + // only check the first checkbox/radio input ( https://github.com/jquery-validation/jquery-validation/pull/2431#issuecomment-1172835268 ) + if ( element.name in checkedCache ) { + continue; + } + checkedCache[ element.name ] = true; + } + + this.check( element ); } return this.valid(); }, @@ -657,8 +670,12 @@ $.extend( $.validator, { return false; } - // Select only the first element for each name, and only those with rules specified - if ( name in rulesCache || !validator.objectLength( $( this ).rules() ) ) { + if ( name in rulesCache ) { + return true; + } + + // return only those with rules specified + if ( !validator.objectLength( $( this ).rules() ) ) { return false; }








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/jquery-validation/jquery-validation/pull/2498.diff

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy