我有以下代码。当我按下保存按钮时,三个 requiredfieldvalidators 运行良好且工作正常。但是我的自定义验证器不起作用。它根本不会触发事件。我有标准文本框和验证摘要控件。是否有任何原因可能无法正常工作?
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtForename" Display="None" ErrorMessage="Must enter a valid first name." />
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtSurname" Display="None" ErrorMessage="Must enter a valid last name." />
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtEmail" Display="None" ErrorMessage="Must enter a valid e-mail address." />
<asp:CustomValidator runat="server" OnServerValidate="CheckAtLeastOnePhoneNumber"
ErrorMessage="Must enter at least one phone number." Display="None"
ValidateEmptyText="True" />
<script runat="server">
void CheckAtLeastOnePhoneNumber(Object s, ServerValidateEventArgs e)
{
if (txtMobileNumber.Text.Equals("") &&
txtWorkNumber.Text.Equals("") &&
txtHomeNumber.Text.Equals(""))
{
e.IsValid = false;
}
}
</script>