Javascript Click handler only if ASP.NET client-side validation succeeds
So basically I want to add a javascript function to a button's Click event and I only want it to execute if the form passes ASP.NET client-side validation.
The easiest conceptual way I can think of is to just run the validation within my function just return if it doesn't pass, but I'm not sure how to call ASP.NET's validators from javascript.
The other way I can think of is maybe set a flag when the button is clicked, then hook into an event after the validation occurs (not sure if this is possible or how to do so) and run the function if the button click flag was set. There is more than 1 button that causes validation which is why the fl开发者_开发技巧ag is needed rather than just assuming the button was clicked if validation happened.
Also open to alternative ideas.
(Using MooTools as our JS library if that matters)
I'd say to just go ahead and attach the function to the button's click event, but then invoke the ASP.NET validation using the following function call:
Page_ClientValidate();
It should return true if the page was valid.
精彩评论