Skip to content

Commit

Permalink
fix(formvalidation): keep old behavior for radiobutton, because there…
Browse files Browse the repository at this point in the history
… is always only 1 value set
  • Loading branch information
lubber-de committed Jan 12, 2019
1 parent 04a182f commit 59e8331
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/definitions/behaviors/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -1036,28 +1036,35 @@ $.fn.form = function(parameters) {
var
$field = module.get.field(field.identifier),
type = rule.type,
isValid = true,
ancillary = module.get.ancillaryValue(rule),
ruleName = module.get.ruleName(rule),
ruleFunction = settings.rules[ruleName],
invalidFields = []
invalidFields = [],
isValid = function(field){
var value = $(field).val();
// cast to string avoiding encoding special values
value = (value === undefined || value === '' || value === null)
? ''
: (settings.shouldTrim) ? $.trim(value + '') : String(value + '')
;
return ruleFunction.call(field, value, ancillary);
}
;
if( !$.isFunction(ruleFunction) ) {
module.error(error.noRule, ruleName);
return;
}
$.each($field, function(index,field){
var value = $(field).val();
// cast to string avoiding encoding special values
value = (value === undefined || value === '' || value === null)
? ''
: (settings.shouldTrim) ? $.trim(value + '') : String(value + '')
;
isValid = ruleFunction.call(field, value, ancillary);
if (!isValid) {
invalidFields.push(field);
if($field.is(selector.radio)) {
if (!isValid($field)) {
invalidFields = $field;
}
});
} else {
$.each($field, function (index, field) {
if (!isValid(field)) {
invalidFields.push(field);
}
});
}
return internal ? invalidFields : !(invalidFields.length>0);
}
},
Expand Down

0 comments on commit 59e8331

Please sign in to comment.