我想在Clientide ClientValidationFunction中动态更改customvalidator消息。在Java脚本我有:在客户端动态更改customvalidator消息
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。 – 2013-03-05 10:05:27
是的。我在“if-else”结构中通过扭动警报(STH)对其进行测试,并且它出现在我的屏幕中。 – Farhad 2013-03-05 10:16:53