views:

203

answers:

1

With some help from other post the related to validating multiple checkboxes, I decided to go with this customer rul

$.validator.addMethod("checkBox", function(value, element) {
    return $("input[type=checkbox]:checked").length > 0;
}, "");

I then call this in the rules section:

field_name:{checkBox:true}

This works great for making sure at least one checkbox is checked in the field, which is really all I need. However, when I started to test I realized I have a checkbox that is set to show/hide a div. This checkbox is being factored into the validation and in return is making the submitted data not valid.

I have tried using ignore:".class_name" but have been unsuccessful in getting the script to actually ignore this field.

Can anyone steer me in the right direction in getting a checkbox to be ignored in the custom validation? Thanks in advance for the help!

+1  A: 

How about changing the "return" line to

return $("input[type=checkbox]:checked:not(.class_name)").length > 0;
JacobM
Sometimes the most simple things can be overlooked. That worked beautifully, thanks for the response!
Taylor