Regex textbox length validator.

  • Thread starter Thread starter darrel
  • Start date Start date
D

darrel

I'm trying to validate the length of characters in a text box. Google seems
to turn up a few examples of using the regex validator with this expression:

^[\S\s]{1, 50}$

(one being minimum length, 50 being maximum).

However, on my page, no matter the length, this validator is always coming
up as invalid. Is the expression incorrect?

-Darrel
 
The ^ and $ shouldn't be used in a RegularExpressionValidator. The space
in the quantifier might be a problem also.

[\S\s]{1,50}
 
ValidationExpression="[\S\s]{10,50}"



Can also be

ValidationExpression="[\w\s]{10,50}" - word or whitespace



The second is actually better, as it gets rid of garbage. Unlikely someone
can type the garbage in, however, so the risk is not high either way.


--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
 
Back
Top