jqueryasp.netrequiredfieldvalidator

disable RequiredFieldvalidator


I have RequiredFieldvalidator and I want in certain cases to disable it.

this is the RequiredFieldvalidator:

<asp:RequiredFieldValidator ID="RfvHul" runat="server" ErrorMessage="Error" ControlToValidate="txtBox" Display="None"></asp:RequiredFieldValidator>

and I've tried to do this but all these lines of code gave me Page_IsValid = false

 $("#RfvHul").attr("disabled", true);

 ValidatorEnable(document.getElementById("<%=RfvHul.ClientID%>"), false);

 document.getElementById("RfvHul").Enabled = false;

 $("#RfvHul").attr("Enabled", false);

Thanks for the help!


Solution

  • You can't just disable it client side and expect the server side code to know about it. You'll have to repeat your disabling logic server side prior to calling Validate().