[jQuery] jQuery Validate -- how to require series of checkboxes when named as array[]

2009-09-23 Thread ripcurlksm

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



[jQuery] jQuery Validate -- how to require series of checkboxes when named as array[]

2009-09-23 Thread ripcurlksm


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=1Red/labelbr/
input name=colors[] id=2 value=2 type=checkbox / 
label
for=2Green/labelbr/
input name=colors[] id=3 value=3 type=checkbox / 
label
for=3Yellow/labelbr/
input name=colors[] id=4 value=4 type=checkbox / 
label
for=4Blue/labelbr/
input name=colors[] id=5 value=5 type=checkbox / 
label
for=5Orange/labelbr/

==

Here is an example:
http://psylicyde.com/misc/jquery-validate/demo/test-checkboxes.php 
http://psylicyde.com/misc/jquery-validate/demo/test-checkboxes.php  
-- 
View this message in context: 
http://www.nabble.com/jQuery-Validatehow-to-require-series-of-checkboxes-when-named-as-array---tp25531286s27240p25531286.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.