Monday, 2 May 2016

Check box Validation

function checkAgreement(source, args) {
        var elem = document.getElementById('checktermandCondition');
        alert(elem.checked)
        if (elem.checked) {
            args.IsValid = true;
        }
        else {
            args.IsValid = false;
        }
    }

  protected void checkAgreement_ServerValidate(object source, ServerValidateEventArgs args)
    {
        args.IsValid = checktermandCondition.Checked;
    }

<asp:CheckBox ID="checktermandCondition" ClientIDMode="Static" runat="server" />

    <asp:CustomValidator ID="CustomValidator1" runat="server" Display="Dynamic" class="errorMsg"  ForeColor="red"
        ErrorMessage="In order to continue with the payment process, you must read and agree to Terms and Conditions." EnableClientScript="true" ClientValidationFunction="checkAgreement"   ValidationGroup="paymentgp"
        onservervalidate="checkAgreement_ServerValidate"></asp:CustomValidator>

No comments:

Post a Comment