The client captures the validation event of the validation control.

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.