CheckBoxList Validation Using JavaScript In Asp.Net
In this tutorial i will teach you CheckBoxList Validation Using JavaScript In Asp.Net.We will put validation on CheckBoxList by using JavaScript.We have to write a function in JavaScript which will check all controls in loop.
Source Code:
01 | <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> |
07 | < title >CheckBoxList Validation Using JavaScript In Asp.Net</ title > |
08 | < style type = "text/css" > |
22 | < script type = "text/javascript" > |
23 | $(document).ready(function () { |
24 | $('#Save').click(function () { |
25 | if ($('#chk1 input:checked').length > 0) { |
39 | < form id = "form1" runat = "server" > |
40 | < h2 >CheckBoxList Validation Using JavaScript In Asp.Net</ h2 > |
41 | < div style = "text-align:center;padding-left:300px" > |
42 | < asp:CheckBoxList ID = "chk1" RepeatDirection = "Horizontal" runat = "server" > |
43 | < asp:ListItem Text = "1" Value = "1" ></ asp:ListItem > |
44 | < asp:ListItem Text = "2" Value = "2" ></ asp:ListItem > |
45 | < asp:ListItem Text = "3" Value = "3" ></ asp:ListItem > |
46 | < asp:ListItem Text = "4" Value = "4" ></ asp:ListItem > |
47 | < asp:ListItem Text = "5" Value = "5" ></ asp:ListItem > |
48 | < asp:ListItem Text = "6" Value = "6" ></ asp:ListItem > |
49 | < asp:ListItem Text = "7" Value = "7" ></ asp:ListItem > |
50 | < asp:ListItem Text = "8" Value = "8" ></ asp:ListItem > |
51 | < asp:ListItem Text = "9" Value = "9" ></ asp:ListItem > |
52 | < asp:ListItem Text = "10" Value = "10" ></ asp:ListItem > |
55 | < asp:Button ID = "Save" Text = "Submit" runat = "server" OnClick = "Save_Click" /> |
One reply on “CheckBoxList Validation Using JavaScript In Asp.Net”
Thanks For Posting such a nice piece of information.