I have a number of checkboxes listed on a page, the rendered html is as follows:
I need these grouped checkboxes to use validation so that at least one of the items is checked.
<input id="element_frm1167_8_1" name="test" class="element checkbox" type="checkbox" value="1" validate="required:true, minlength:2">
<input id="element_frm1167_8_2" name="test" class="element checkbox" type="checkbox" value="1" >
<input id="element_frm1167_8_3" name="test" class="element checkbox" type="checkbox" value="1" >
I've looked at an example from http://jquery.bassistance.de/validate/demo/radio-checkbox-select-demo.html
However, when I call form.Validate() I dont get any validation happening.
Please could someone point me in the right direction.
I'd say that chances are you haven't configured the metadata plugin (or included it at all). That's what handles taking the validate
attribute in your checkbox, and turning that into rules for the validation plugin. To get what you want in a simpler way, you can just specify the rules directly in your validate call:
$('#myForm').validate({
rules: {
test: {
required: true,
minlength:2
}
}
});
See it in action here: http://jsfiddle.net/ryleyb/EWbED/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With