Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp.net client side validation

Status
Not open for further replies.

Thrakazog

Programmer
Dec 10, 2001
48
US
I've got a couple APS.NET RequiredFieldValidators on my web page. I also have some custom javascript that raises a confirm message box that prompts for OK/Cancel based on what the user entered. This confirm message box is triggered when the user hits "Save".

My problem is that the confirm message box is showing up before the required fields have been checked for validation. I can have empty fields and the prompt for OK/Cancel still shows up. How can I run the client side validation for my asp.net validators before my javascript? Ideally I would like to run the validation and not show my confirm message if it fails.

Anyone know how I can do this?

Thanks,
 
I believe the validation script runs before submittal, but after the actual button click, so you will probably have to look outside of the button's onclick attribute to make things happen.

The first think I'd investigate is Page.RegisterOnSubmitStatement(), where you make sure you register your confirm script after the validation script registers.
 
Found my answer. You can call Page_ClientValidate(); at any time to validate a page. Then you can use Page_isValid to see the results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top