Burt Burt - 2 months ago 9
ASP.NET (C#) Question

ValidatorEnable is not defined

I am trying to enable and disable a required field validator using javascript but keep getting the error message ValidatorEnable is not defined. PLease find code below, any help would be great.

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);


Code Behind

protected void Page_Load(object sender, EventArgs e)
{
rblCV.Attributes.Add("onClick", string.Format("ShowCvOptions();"));
...
}

Answer

Make sure that function ValidatorEnable is placed before calling from any other place.

Comments