JQuery Validation Plugin with CheckBox Group

I have several checkboxes listed on the page, the displayed html is as follows:

I need these grouped checkboxes to use validation so that at least one of the elements 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 reviewed an example from http://jquery.bassistance.de/validate/demo/radio-checkbox-select-demo.html

However, when I call form.Validate (), I get no confirmation.

Please can someone point me in the right direction.

+5
source share
3 answers

, ( ). , validate . , , :

$('#myForm').validate({
 rules: {
    test: {
        required: true,
        minlength:2            
    }
 } 
});

: http://jsfiddle.net/ryleyb/EWbED/

+5

, name="test[]" name="test"

+1

Publish this for people like me who find this thread and want to send multiple values ​​to PHP after checking (maybe almost everyone?). Include brackets in the form element names

<input id="element_frm1167_8_3" name="test[]" class="element checkbox" type="checkbox" value="1" >

and in the verification identifier

rules: {
  'test[]': {
    required: true,
    minlength:2            
  }
} 
0
source

All Articles