I have a group of checkboxes that I need to specify uniquely to store the values ββin the database separately. However, using the jquery validate plugin, I cannot check a group with different names.
<label>Would you like to compete?</label> <input type="checkbox" name="compete1" value="2" class="competecheckbox" > <label for="compete_no">No</label> <input type="checkbox" name="compete2" value="1" class="competecheckbox"> <label for="compete_yes">Yes</label> <div id="competeyes"> <label class="competeyestxt" hidden=true>Which Location?</label> <textarea rows="4" cols="40" maxlength="2000" name="competeyestextarea" class="competeyestxt" hidden="true"> </textarea> </div>
I tried adding
$.validator.addClassRules( "competecheckbox", {required: true, minlength: 1});
This view works, but it shows 2 error messages. One for each of the competing classes of the matching class.
The problem is that even if the user selects Compete1, the validation error message still remains for compet2.
How to clear both messages when the user selects at least one checkbox?
thanks
source share