Combine regular expression validator with javascript function?

  • Thread starter Thread starter Dot net work
  • Start date Start date
D

Dot net work

Hello.

Say I have a .net textbox that uses a .net regularexpressionvalidator.
If the regular expression fails, is it possible to launch a small
client side javascript function to do something, such as change the
border color of the textbox to red? That would look quite nice: if
the expression fails, the red validator text is shown, plus the
textbox's border goes red.

TIA,
-dnw.
 
I was not able to somehow combine the regular expression validator
control with a client side javascript function, so instead I took the
regular expression that I needed and put it inside a custom validator
client side function, then added on some extra javascript that changed
the textbox border to red.

-dnw.
 
There is a solution that avoids rewriting every validator. It requires using
a replacement to Microsoft's validators that is designed to handle this kind
of communication. Microsoft's validators are limited to showing an error
message in the location of the validator. There are other ways to
communicate to the user: setting focus to the field, changing the field,
label or background color, blinking the error message and putting up an
alert. "Professional Validation And More"
(http://www.peterblum.com/vam/home.aspx) has all of these capabilities
supporting its 22 validators. Its designed to avoid writing custom code and
hacks due to the many limitations of Microsoft's validators.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
Back
Top