First let me thank all of you for your amazing efforts and help thus far. Now to the question.
I have five checkboxes and at least one of the five needs to be checked to validate as required.
I have seen a few methods of how to do this but I can't seem to make any of them work.
Now I am using both the validate plugin and metadata plugin. How can I easily say if one checkbox with class required_group
is checked the rest are no longer required? I have also given all checkboxes class="required"
As always Thanks in Advance!
Edit: My apologies for improperly phrasing the question. I would use radio buttons or selects as it is quite easier but it is requested that I use checkboxes. Again thank you for your time and sorry for the confusion.
FINAL EDIT So here is how I did it in case anyone else ever needs to.
jQuery.validator.addMethod('ClassAppliedToCheckBoxes', function(value, element, checked) {
var $module = $(element).parents('.YourContainerClass');
return $module.find('input:checked').length;
});
jQuery.validator.addClassRules("ClassAppliedToCheckBoxes", {
'ClassAppliedToCheckBoxes' : true
});
jQuery.validator.messages.required_group = 'Please check at least one of these fields.';