[jQuery] jQuery Validate -- how to require series of checkboxes when named as array[]
I have a working example of jQuery validate working in the link below.
The newsletter checkbox is required and working. However, the "colors"
checkboxes are all named as an array ( ex: name="color[]" ), and so
the problem lies in the validation code, where it uses the name of the
element to require elements ( ex: newsletter: "required" ).
$("#testform").validate({
rules: {
// how do i name colors below?
// colors[] ???
// fieldset#color_preference input:checkbox ???
colors: {
required: true,
minlength: 1
},
newsletter: "required"
},
messages: {
colors: "*Required",
newsletter: "*Required"
}
});
Here is an example:
http://psylicyde.com/misc/jquery-validate/demo/test-checkboxes.php