我想在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