Required Field Validator for CheckBoxList
When you use asp check box list and want to apply required field validator then follow below example.
<asp:CheckBoxList ID="chkDemoList" runat="server" >
<asp:ListItem Text="India" Value="IN"></asp:ListItem>
<asp:ListItem Text="United States of Americs" Value="USA"></asp:ListItem>
<asp:ListItem Text="Japan" Value="JP"></asp:ListItem> </asp:CheckBoxList> <asp:CustomValidator runat="server" ID="cvDemoList" ClientValidationFunction="ValidateDemoList" ErrorMessage="Required Field" ></asp:CustomValidator> // javascript to add to your aspx page function ValidateDemoList(source, args) { var chkListModules= document.getElementById ('<%= chkDemoList.ClientID %>'); var chkListinputs = chkListModules.getElementsByTagName("input"); for (var i=0;i<chkListinputs .length;i++) { if (chkListinputs [i].checked) { args.IsValid = true; return; } } args.IsValid = false; }
Thank You
ReplyDeleteIt is really a great work and the way in which u r sharing the knowledge is excellent.
ReplyDeleteThanks for helping me to understand basic concepts. As a beginner in Dot Net programming your post help me a lot.Thanks for your informative article.
dot net training and placement in chennai |
dot net course fees
CheckBoxList client side validation in Radgrid is possible..?
ReplyDeleteimpressive blog with great information.
ReplyDeleteJava training in Chennai
Java training in Bangalore
Java training in Hyderabad
Java Training in Coimbatore
Java Online Training