Q:
Hi,
Do u guys know if we can trap in client side when a validation is taking place or when it s finished in client side. I am talking about validation controls like: requiredfieldvalidator, regularexpressionvalidator... etc
More precisely, I need to trap the event when the regularexpressionvalidator succeeds or when it fails, but I want to handle that client side. Is that possible? How please?
Thank you
A:
Hi,
Client-side validation library has a few methods for example validatorvalidate (you can view them with reflector from system. Web. DLL's resources and viewing webuivalidation. JS)
Function validatorvalidate (Val, validationgroup, event ){
// There's some script here
}
1. So with JavaScript basically taking reference to the old validatorvalidate () within a variable
VaR oldvalidatorvalidate = validatorvalidate;
2. creating your own validatorvalidate
Function myvalidatorvalidate (Val, validationgroup, event ){
// First call the original one
Oldvalidatorvalidate (Val, validationgroup, event );
// Here you can check VAL. isvalid-e. g write your logic here, like check for the correct validator etc
Alert (Val. ID + ":" + val. isvalid );
}
3. Set new reference in Javascript
Validatorvalidate = myvalidatorvalidate;
Now when validatorvalidate is called by client-side validation framework, it callyour myvalidatorvalidate method, which delegates the job first to the original method, and then does its logic after the "base" method has done its job.
Http://forums.asp.net/p/1282363/2454378.aspx