简体   繁体   中英

ASP.NET Validators - is there a way to call a function in client side when validation ends?!

Let say there is a RequiredFieldValidator and when validation happens I want to make some changes on the page (like show a hidden div) if validation fails,

Is there a way to call a function in js when the validation ends?! or do you have any other idea?!

Thanks,

Adler!

Why not write your own validator that extends RequiredFieldValidator?

This tutorial looks like it could help point you in the right direction:

Or you can write custom client side java validator:

<script type="text/javascript" language="javascript">
    function ValidateDropDown(source, arguments) {
        if (arguments.Value === 'NA') {
            arguments.IsValid = false;
        }
    }
</script>

<asp:CustomValidator ID="CoverServerCustomValidator" runat="server" ErrorMessage="<img src='../Themes/WebOrder/Images/weborder_Error.png'>"ToolTip="A Size is Required" Display="Dynamic" CssClass="Error" ValidationGroup="Sizing" OnServerValidate="ValidateDropDown" ControlToValidate="ddlCover" EnableClientScript="true"></asp:CustomValidator>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM