I am using jQuery validation plugin (http://bassistance.de/jquery-plugins/jquery-plugin-validation/)
Following code is a part of form
<input type="checkbox" name="a_r[]" value="one" id="ar_one" />Visitors
<input type="checkbox" name="a_r[]" value="two" id="ar_two" />Actions
<input type="checkbox" name="a_r[]" value="three" id="ar_three" />Referrers
I need to check if any 2 checkboxes are checked or not, only if a particular radio value is set to ‘y’
<input type="radio" name="allowusage" id="allowusage" value="n" checked />No
<input type="radio" name="allowusage" id="allowusage" value="y" />Yes
I have written following rule, but it’s not working some how.
a_r:{required:function() {return jQuery('input[name|="allowusage"]:checked').val() == 'y';},minlength:2},
Basically, I need rule as such
If allowusage value is ‘y’, then checkbox selection is required, otherwise not.
and if allowusage value is ‘y’ then atleast 2 checkbox need to be selected
rule should be like