Pages

Subscribe:

Sunday, 5 January 2014

Validate Checkbox using custom validator


<script type="text/javascript">
 function ValidateCheckBox(sender, args) {
            if (document.getElementById("<%=chkactivity.ClientID %>").checked == true) {
                args.IsValid = true;
            } else {
                args.IsValid = false;
            }
        }
         
    </script>

 <asp:checkbox id="chkactivity" runat="server" text="Privacy Plicy"></asp:checkbox>
                                            &nbsp;&nbsp;
                                            <asp:customvalidator clientvalidationfunction="ValidateCheckBox" display="Dynamic" errormessage="Required!" forecolor="Red" id="CustomValidator1" runat="server">Required!</asp:customvalidator>

1 comments:

Beeru Prasad said...

Good One dost, very nice and knowledgeable post.

thanks,

Post a Comment