I am trying to use the validation plugin to validate a set of checkboxes which are created by my CMS (drupal) so are not changeable - and which look like this:
<code> <div class="form-item" id="edit-pollutants-storage-tanks-wrapper"> <label class="option"><input type="checkbox" name="pollutants [tanks]" id="edit-pollutants-storage-tanks" value="tanks" class="form-checkbox" /> a. Tanks (Oil, fuel chemicals)</label> </div> <div class="form-item" id="edit-pollutants-rubbish-wrapper"> <label class="option"><input type="checkbox" name="pollutants [rubbish]" id="edit-pollutants-rubbish" value="rubbish" class="form- checkbox" /> b. Rubbish</label> </div>... </code> I want the user to select at least one of the pollutant checkboxes. As you can see the name is in the format pollutants[xxxx]. I don't want to have to validate each option, cause I want them only to have to choose one of the pollutants. I tried "pollutans[]" but that didn't work. So now I'm trying to do it by doing a combination of things 1. putting a required on the first one if count of checkboxes.size()== 0 2. looking for an onclick to remove the rule if any of the checkboxes are then checked. But the remove rule is not working. <code> $("inp...@name^='pollutants']").change(function(){ $("inp...@name^='pollutants']").rules("remove"); }); $("#myForm").validate({ rules: { "pollutants[tanks]": "required" } }); </code> Any suggestions? I am rather frustrated.