Content-Length: 2333 | pFad | http://github.com/jquery-validation/jquery-validation/pull/2498.patch

thub.com From 2933b3b04da556288af24c65ff152c0a426e01c3 Mon Sep 17 00:00:00 2001 From: Aaron Queen Date: Wed, 4 Sep 2024 00:12:57 -0600 Subject: [PATCH 1/2] Allow input name arrays --- src/core.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/core.js b/src/core.js index 240e2737b..391413c90 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[ 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; } From b041216a41348d1138a42e110e959faa4d339208 Mon Sep 17 00:00:00 2001 From: Aaron Queen Date: Wed, 4 Sep 2024 00:59:09 -0600 Subject: [PATCH 2/2] Allow input name arrays --- src/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.js b/src/core.js index 391413c90..6ebbf9c11 100644 --- a/src/core.js +++ b/src/core.js @@ -457,7 +457,7 @@ $.extend( $.validator, { this.prepareForm(); for ( var i = 0, elements = ( this.currentElements = this.elements() ); elements[ i ]; i++ ) { - var element = elements[ i ]; + var element = elements.eq(i); var type = element.attr( "type" ); if ( type === 'checkbox' || type === 'radio' ) {








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.patch

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy