By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,638 Members | 2,241 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,638 IT Pros & Developers. It's quick & easy.

Combine regular expression validator with javascript function?

P: n/a
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.
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.

do***@hotmail.com (Dot net work) wrote in message news:<77**************************@posting.google. com>...
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.

Nov 18 '05 #2

P: n/a
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: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
"Dot net work" <do***@hotmail.com> wrote in message
news:77**************************@posting.google.c om...
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.

do***@hotmail.com (Dot net work) wrote in message

news:<77**************************@posting.google. com>...
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.

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.