Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Formvalidation] Radio buttons do not validate if the first is disabled #372

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/definitions/behaviors/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ $.fn.form = function(parameters) {
if(!$field || $field.length === 0) {
return true;
}
else if($field.is('input[type="checkbox"]')) {
else if($field.is(selector.checkbox)) {
return !$field.is(':checked');
}
else {
Expand Down Expand Up @@ -980,17 +980,21 @@ $.fn.form = function(parameters) {
module.debug('Using field name as identifier', identifier);
field.identifier = identifier;
}
if($field.prop('disabled')) {
var isDisabled = true;
$.each($field, function(){
if(!$(this).prop('disabled')) {
isDisabled = false;
return false;
}
});
if(isDisabled) {
module.debug('Field is disabled. Skipping', identifier);
fieldValid = true;
}
else if(field.optional && module.is.blank($field)){
module.debug('Field is optional and blank. Skipping', identifier);
fieldValid = true;
}
else if(field.depends && module.is.empty($dependsField)) {
module.debug('Field depends on another value that is not present or empty. Skipping', $dependsField);
fieldValid = true;
}
else if(field.rules !== undefined) {
$.each(field.rules, function(index, rule) {
Expand Down