views:

14

answers:

1

Hello friends,

I have some text fields and a button on my aspx. The text fields are validated using required field validators. On button i have set OnClientClick() event to do certain JS operations.

The problem here is that, the JS function is called before validations are completed. That is i need to validate first and then call js on client click event of button.

Can anybody help me?

Thanks for sharing your time.

+2  A: 

You could do the client side validation manually:

<asp:Button ID="Button1" runat="server" 
    OnClientClick="if (Page_ClientValidate()) return YourFunction(); else return false;"
    OnClick="Button1_Click" />

Remember to do whatever checking server side as well since you javascript could be manipulated and/or bypassed.

Kelsey
Thanks Kelsey. Yes it works.
IrfanRaza