Checkbox custom validation in asp.net

Hello,

In this post I will explain how to validate ASP.Net Checkbox control using ASP.Net Custom Validator and JavaScript.

Javascript:

function CheckboxValidation(sender, args) {
            if (document.getElementById("<%=YourCheckboxControlID.ClientID %>").checked == true) {
                args.IsValid = true;
            } else {
                args.IsValid = false;
            }
        } 

Checkbox:


asp:CheckBox ID="YourCheckboxControlID" runat="server" />

Custom Validator:



Button:




Here, You can see the I have used ClientValidationFunction property of asp.net CustomValidator. Which is used to validate control by using javascript function. So when I click on the button then it validates the checkbox whether it is is checked or not.

Hope this will help you !!!….

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>