Regularexpression validator on multiline text box

S

Stephan Bour

Follow up to previous question:
I¹m trying to validate a multipline asp text box that can have a maximum of
150 word characters but any number of white space, carriage returns or tabs.
I tried several regex that pass testing on regexplib.com but fail on the
page
This for example doesn¹t work properly:

ValidationExpression="^\w{1,150}|\s{0,}$"

I get a validation error if any non-word character is added, regardless of
the total length of the string.

I think I'm having a problem because the text box is multiline and the regex
doesn't check it as single line. I have solved that problem before by using
RegexOptions.Singleline in the code behind file but I don't know how to do
that within the asp RegularExpressionValidator tag.
Any idea?
Thanks,
Stephan.
 
N

Nicole Calinoiu

Stephan,

You'll need to allow white space characters before, between, and after your
word characters. Try this instead:

^\s*(\w\s*){1,150}\s*$

HTH,
Nicole
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top