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” ).

<script>
$("#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"
	}
});
</script>
<input name="colors[]" id="1" value="1" type="checkbox" /> <label for="1">Red</label><br/>
<input name="colors[]" id="2" value="2" type="checkbox" /> <label for="2">Green</label><br/>
<input name="colors[]" id="3" value="3" type="checkbox" /> <label for="3">Yellow</label><br/>
<input name="colors[]" id="4" value="4" type="checkbox" /> <label for="4">Blue</label><br/>
<input name="colors[]" id="5" value="5" type="checkbox" /> <label for="5">Orange</label><br/>

Here is an example:
http://psylicyde.com/misc/jquery-validate/demo/test-checkboxes.php

I think you want this… You have to put it in a string. Voila!


$('#testform').validate({
  rules : {
        'colors[]': { required: true, minlength: 1 }
  }
});

Read more about it here: http://docs.jquery.com/Plugins/Validation/Reference#Fields_with_complex_names_.28brackets.2C_dots.29

Very nice! Thanks!