Thank you for providing a very good example how to validate checkboxlist, Validate ASP.Net CheckBoxList (at least one CheckBox checked) using Custom Validator
It works great!
I would like to have another selection "Other" to the <asp:CheckBoxList"> and a textbox. If the user selects "Other" option then he/she must to fill out the textbox. How would we do that? Thank so much for your help.
The textbox doesn't need to be visible. Thanks so much for your help.
Select Fruits<br />
<asp:CheckBoxList ID="chkFruits" runat="server">
<asp:ListItem Text="Mango" />
<asp:ListItem Text="Apple" />
<asp:ListItem Text="Banana" />
<asp:ListItem Text="Pineapple" />
<asp:ListItem Text="Guava" />
<asp:ListItem Text="Grapes" />
<asp:ListItem Text="Papaya" />
<asp:ListItem Text="Other" />
</asp:CheckBoxList>
<asp:TextBox id="txtOtherfruit" rows="5" TextMode="multiline"
runat="server" />
<asp:CustomValidator ID="CustomValidator1" ErrorMessage="Please select at least one item."
ForeColor="Red" ClientValidationFunction="ValidateCheckBoxList" runat="server" />
<br />
<br />
<asp:Button ID="btnSubmit" Text="Submit" runat="server" /><br />