0

我想通过 ClientValidationFunction 在客户端动态更改 customvalidator 消息。在java脚本中我有:

function valnationalid(source, arguments) {     
    if (arguments.Value == ""){         
        source.errormessage = "custom message here";
        arguments.IsValid = false;
    } else if (arguments.Value == "Something else"){
        source.errormessage = "another custom message here";
        arguments.IsValid = false;
    }
}

和身体:

<input runat="server" id="txtnationalid" maxLength="10" name="txtnationalid" class='person ltr glow-onfocus customerCode required number' dir="ltr" />
<asp:CustomValidator ID="valnationalid1" runat="server" EnableClientScript="true" ClientValidationFunction="valnationalid"  ValidateEmptyText="True" Display="Dynamic" ControlToValidate="txtnationalid"> </asp:CustomValidator>                            

但是我的页面中没有显示任何消息。

4

1 回答 1

1

以下对我有用:

代替

source.errormessage = "custom message here";

source.innerHTML = "custom message here";
于 2013-03-05T10:47:11.347 回答