Skip to content

Commit 5ed766b

Browse files
committed
fixed validation for elements with name defined as array
use case: <input name="customer[email]" type="text" data-validation="validate_confirmation"> <input name="customer[email]_confirmation" type="text">
1 parent 2f9376a commit 5ed766b

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

jquery.formvalidator.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@
163163
* @param settings
164164
*/
165165
validate : function(language, settings) {
166-
167166
/*
168167
* Config
169168
*/
@@ -215,18 +214,16 @@
215214
// Validate element values
216215
//
217216
$form.find('input,textarea,select').each(function() {
218-
219217
var $el = $(this);
220218
var elementType = $el.attr('type');
221219
if (!jQueryFormUtils.ignoreInput($el.attr('name'), elementType, config)) {
222-
223220
// input of type radio
224221
if(elementType === 'radio') {
225222
var validationRule = $el.attr(config.validationRuleAttribute);
226223
if (typeof validationRule != 'undefined' && validationRule === 'required') {
227224
var radioButtonName = $el.attr('name');
228225
var isChecked = false;
229-
$form.find('input[name=' + radioButtonName + ']').each(function() {
226+
$form.find('input[name="' + radioButtonName + '"]').each(function() {
230227
if ($(this).is(':checked')) {
231228
isChecked = true;
232229
return false;
@@ -980,11 +977,10 @@ jQueryFormUtils.validate = function(value, el, language, config, form) {
980977
if (validationRules.indexOf('validate_swesc') > -1 && !jQueryFormUtils.validateSwedishSecurityNumber(value)) {
981978
return validationErrorMsg || language.badSecurityNumber;
982979
}
983-
984980
// confirmation
985981
if (validationRules.indexOf('validate_confirmation') > -1 && typeof(form) != 'undefined') {
986982
var conf = '';
987-
var confInput = form.find('input[name=' + el.attr('name') + '_confirmation]').eq(0);
983+
var confInput = form.find('input[name="' + el.attr('name') + '_confirmation"]').eq(0);
988984
if (confInput) {
989985
conf = confInput.val();
990986
}

0 commit comments

Comments
 (0)