【发布时间】:2013-03-05 09:58:41
【问题描述】:
我想通过 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>
但我的页面中没有显示任何消息。
【问题讨论】:
-
你的 JS 是否执行。还有你想做什么,你的验证器总是返回 false。
-
是的。我通过在“if-else”结构中扭动警报(STH.)来测试它,它出现在我的屏幕上。
标签: jquery asp.net validation