views:

20

answers:

1

Is there away to call a javascript function after a validation control fails validation?

+1  A: 

Check article "ASP.NET Validation in Depth" from MSDN - section of particular interest is Client Side Validation that provides client side API. You can use isvalid property of a validator object to decide if its valid or not. Validator objects (on client side) can be referred using ClientID property of server side validator control.

One of the way to achieve what you want can be

  1. Turn off ASP.NET validation by setting js variable Page_ValidationActive to false
  2. When post-back happens iterate via all validators using Page_Validators property and validate each calling ValidatorValidate.
  3. If validator of interest in not valid then call your function.
VinayC