我正在尝试使用 javascript 启用和禁用必填字段验证器,但不断收到错误消息 ValidatorEnable is not defined。请在下面找到代码,任何帮助都会很棒。
ASP.NET
<asp:RequiredFieldValidator EnableClientScript="True" Display="None" ID="rfvMostRecentEmployer" ControlToValidate="txtMostRecentEmployer" runat="server" ErrorMessage="Most recent employer title is a required field"></asp:RequiredFieldValidator>
Javascript
var validatorMostRecentEmployer = document.getElementById('<%= rfvMostRecentEmployer.ClientID %>');
ValidatorEnable(validatorMostRecentEmployer, !hasCv);
代码背后
protected void Page_Load(object sender, EventArgs e)
{
rblCV.Attributes.Add("onClick", string.Format("ShowCvOptions();"));
...
}