Skip to content

Commit 9e3c657

Browse files
committed
AC-10826 :: Storefront Bundle Checkbox Validation Error message count more than 1
1 parent 995a05c commit 9e3c657

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

lib/web/jquery/jquery.validate.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,34 @@
471471
},
472472

473473
checkForm: function() {
474-
this.prepareForm();
475-
for ( var i = 0, elements = ( this.currentElements = this.elements() ); elements[ i ]; i++ ) {
476-
this.check( elements[ i ] );
474+
if ($(this.currentForm).find('.bundle').length > 0) {
475+
this.prepareForm();
476+
var elements = this.elements();
477+
var optionMap = {};
478+
for (var i = 0; i < elements.length; i++) {
479+
var el = elements[i];
480+
var optionNumber = el.id.split('-')[2];
481+
if (!optionMap[optionNumber]) {
482+
optionMap[optionNumber] = [];
483+
}
484+
optionMap[optionNumber].push(el);
485+
}
486+
for (var option in optionMap) {
487+
if (optionMap.hasOwnProperty(option)) {
488+
var group = optionMap[option];
489+
if (group.length > 0) {
490+
this.check(group[0]);
491+
}
492+
}
493+
}
494+
return this.valid();
495+
} else {
496+
this.prepareForm();
497+
for ( var i = 0, elements = ( this.currentElements = this.elements() ); elements[ i ]; i++ ) {
498+
this.check( elements[ i ] );
499+
}
500+
return this.valid();
477501
}
478-
return this.valid();
479502
},
480503

481504
// https://jqueryvalidation.org/Validator.element/

0 commit comments

Comments
 (0)