Before starting, I would like to say that the code created by ASP.NET for CheckBoxLists is probably the worst thing I've ever seen.
Anyway
I am using the jQuery validation plugin to validate an ASP.net form. Some checkboxes need to be checked. They are generated by the CheckBoxList control.
<asp:CheckBoxList ID="CBContext" runat="server" RepeatColumns="2" DataSourceID="sqlLibraryEnquiries" DataTextField="value" DataValueField="value" name="topic"> </asp:CheckBoxList>
This control produces the following abomination xHTML
<table id="MainContent_CBContext" name="topic"> <tr> <td> <input id="MainContent_CBContext_0" type="checkbox" name="ctl00$MainContent$CBContext$0" value="Business" /><label for="MainContent_CBContext_0">Business</label> </td> <td> <input id="MainContent_CBContext_2" type="checkbox" name="ctl00$MainContent$CBContext$2" value="Legal" /><label for="MainContent_CBContext_2">Legal</label> </td> </tr> <tr> <td> <input id="MainContent_CBContext_1" type="checkbox" name="ctl00$MainContent$CBContext$1" value="Business Development" /><label for="MainContent_CBContext_1">Business Development</label> </td> <td> <input id="MainContent_CBContext_3" type="checkbox" name="ctl00$MainContent$CBContext$3" value="Library" /><label for="MainContent_CBContext_3">Library</label> </td> </tr> </table>
The problem I ran into is getting the jQuery Validator plugin to connect to the checkbox list. In the "My Rules" section for all other fields, I can get their names for them, for example, ctl00 $ MainContent $ tbActions: but all the flags have different names.
The cb_selectone rule does not start because the object that I am trying to check has not been found. I have tried the following identifiers. CBContext, ctl00 $ MainContent $ CBContext, MainContent_CBContext and checkboxes.
$("#Form1").validate({ rules: { //WHAT GOES HERE???? --------->> CBContext or ctl00$MainContent$CBContext or MainContent_CBContext or checkboxes all don't work: { cb_selectone: true } } });
Thanks for your help.
CM
source share