我正在使用自定义验证器来调用 javascript 函数进行验证。我的问题是我需要能够动态更改错误消息。这是代码:
<asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="fcnValid1"
ErrorMessage="" Display="None" ValidateEmptyText="True">
</asp:CustomValidator>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode="List" ShowMessageBox="True" ShowSummary="False" />
function fcnValid(source, args) {
var Status = document.getElementById("<%=ddlStatus.ClientID%>").value
if (Status == "In Underwriting") {
if (document.getElementById("<%=txtRequestor.ClientID%>").value == "") {
//sender.errormessage = "Test1"
//sender.innerHTML = "Test2";
document.getElementById("<%=txtRequestor.ClientID%>").focus();
args.IsValid = false;
}
}
}