I have a radiobuttonlist like this and i am trying to make this a required field and am using form validation(jquery validation plugin).
<asp:RadioButtonList ID="PlateType1" runat="server" CssClass="rbclass required">
<asp:ListItem>New</asp:ListItem>
<asp:ListItem>Renewal</asp:ListItem>
</asp:RadioButtonList>
Obviously behind the scenes, asp.net engine generates a table and so the form validation plugin does not understand the CssClass required function.So it never validates my list, though i dont select anything on submit.
How do i rewrite so that i can use jquery validation plugin?
my rbclass is
.rbclass
{
float:left;
display:block;
}
On inspecting the elements through firebug, this is what is happening. The label class=”error” is generated right after the radiobutton. How can i control that, so that it is after New.
<td>
<input id="MainContent_PlateType1_0" class="ui-wizard-content ui-helper-reset ui-state-default required error" type="radio" value="New" name="ctl00$MainContent$PlateType1">
<label class="error" for="ctl00$MainContent$PlateType1" generated="true">This field is required.</label>
<label for="MainContent_PlateType1_0">New</label>
</td>
Here is my updated markup which references the generated id name
<label for="PlateType1" class="rblabel">This plate is: <span class="required_field">*</span></label>
<asp:RadioButtonList ID="PlateType1" runat="server" CssClass="rbclass">
<asp:ListItem>New</asp:ListItem>
<asp:ListItem>Renewal</asp:ListItem>
</asp:RadioButtonList>
<span>
<label class="error" for="ctl00$MainContent$PlateType1" >Please select either New or Renewal</label>
</span>
you could have something like this on document ready handler
or if you want to have this inside an external js file