I´m using jquery validate plugin to ensure at least one from a group of three checkboxes is checked and it´s woking fine. But I want validate these checkboxes only if the ra
You could try the built-in functionality:
$( "#itemForm" ).validate({
rules: {
opt01: {
required: "#resp01-sim"
}
}
});
http://jqueryvalidation.org/required-method/#example:-makes-details-required-only-if-#other-is-checked
You simply need to alter the logic of your custom method.
$.validator.addMethod('require-one', function(value) {
if ($('#resp01-sim').is(':checked')) {
return $('.require-one:checked').size() > 0;
} else {
return true;
}
}, 'Selecione pelo menos uma das opções.');
DEMO: http://jsfiddle.net/TnmGr/4/