Burt Burt - 6 months ago 59
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:RequiredFieldValidator EnableClientScript="True" Display="None" ID="rfvMostRecentEmployer" ControlToValidate="txtMostRecentEmployer" runat="server" ErrorMessage="Most recent employer title is a required field"></asp:RequiredFieldValidator>


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


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