我想通过 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>
但是我的页面中没有显示任何消息。