top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How do I make a checkbox required on an ASP.NET form?

+2 votes
402 views

How do I make a checkbox required on an ASP.NET form?

posted May 26, 2014 by Khusboo

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script type = "text/javascript">
        function ValidateCheckBox(sender, args) {
            if (document.getElementById("<%=CheckBox1.ClientID %>").checked == true) {
                args.IsValid = true;
            } else {
                args.IsValid = false;
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:CheckBox ID="CheckBox1" runat="server" />
    <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Required" ClientValidationFunction = "ValidateCheckBox"></asp:CustomValidator><br />
    <asp:Button ID="Button1" runat="server" Text="Submit"/>
    </form>
</body>
</html>
answer Nov 18, 2014 by Manikandan J
Similar Questions
+2 votes

If somke error occurs i want the system to redirect to some other page and not show he error message.

<customErrors
   mode="RemoteOnly" 
   defaultRedirect="~/Error.aspx" />

This is not working.

+2 votes

How do I properly align pdf...?? I have different tables for different run..

0 votes

How to get all values along with control Id using Jquery in ASP.NET?

...