0

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 Answer 1

1

How about changing the "return" line to

return $("input[type=checkbox]:checked:not(.class_name)").length > 0;
Sign up to request clarification or add additional context in comments.

1 Comment

Sometimes the most simple things can be overlooked. That worked beautifully, thanks for the response!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.