使用CustomValidate自定义验证控件

添加控件:

<asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="ValidateDropQY"
ControlToValidate="dropqy" Display="Dynamic" ErrorMessage="此处有错误" ValidationGroup="val"></asp:CustomValidator>

添加JS:

function ValidateDropQY(source, args) {
        if (args.Value == "--请选择区域--" || args.Value == "0") {
            args.IsValid = false;
        }
        else {
            args.IsValid = true;
        }
    }

posted @ 2012-08-22 11:33  jsping68  阅读(290)  评论(0编辑  收藏  举报