troubleshooting Question

Why doesn't my javascript code I disable a required field validator?

Avatar of Bruce
BruceFlag for United States of America asked on
.NET ProgrammingASP.NETJavaScript
5 Comments1 Solution308 ViewsLast Modified:
I have an OnClientClick assigned to a javascript function that "disables" the validation when a certain button is clicked.

I have this button within a FormView:

<asp:Button ID="btnSaveAndExitTop" runat="server" Text="Save & Exit" OnClick="btnSave_Click" style="margin-right:10px;" CssClass="clsFlatButton2" OnClientClick="javascript: DisableValidators();"/>

This is the javascript to disable all the validators on the page:

 function DisableValidators()
    for(var i=0;i< Page_Validators.length;i++)
        ValidatorEnable(Page_Validators[i], false)

The javascript fires.  When I step through the javascript I can see the enabled element of the validator turn to false but the page valiation still fires and the errors are still displayed.

What am I doing wrong here?

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros