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

Regular Expression for multiline validation

P: n/a
To validate the length of a multiline textbox, I'm told that I have to use a
regular expression validator. The regular expression below limits it to 25
characters in length, but if the user enters a hard return, it bombs
regardless of length. How do you allow hard returns in the following
regular expression? Thanks in advance!

^.{0,25}$

Mark
Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies

P: n/a
Take a look @ Tips and Trick Section Recent Validating MaxLength of the TextArea using CustomValidator

http://www.aspnet101.com/aspnet101/tips.aspx

"Mark" <fi**************@umn.edu> wrote in message news:eM**************@tk2msftngp13.phx.gbl...
To validate the length of a multiline textbox, I'm told that I have to use a
regular expression validator. The regular expression below limits it to 25
characters in length, but if the user enters a hard return, it bombs
regardless of length. How do you allow hard returns in the following
regular expression? Thanks in advance!

^.{0,25}$

Mark



Nov 17 '05 #2

P: n/a
Mark,

Sorry, I took that expression from another forum's post. I had never
actually tested it myself. My bad. I just played around a bit. Try this
instead: ^[\s\S]{0,10}$

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Mark" <fi**************@umn.edu> wrote in message
news:es**************@TK2MSFTNGP12.phx.gbl...
That looks great for server side validation, but what about client side?
Thanks.

Mark

"Sonali.NET[MVP]" <xb********@hotmail.com> wrote in message
news:ug**************@TK2MSFTNGP12.phx.gbl...
Take a look @ Tips and Trick Section Recent Validating MaxLength of the
TextArea using CustomValidator

http://www.aspnet101.com/aspnet101/tips.aspx

"Mark" <fi**************@umn.edu> wrote in message
news:eM**************@tk2msftngp13.phx.gbl...
To validate the length of a multiline textbox, I'm told that I have to use
a
regular expression validator. The regular expression below limits it to

25 characters in length, but if the user enters a hard return, it bombs
regardless of length. How do you allow hard returns in the following
regular expression? Thanks in advance!

^.{0,25}$

Mark


Nov 17 '05 #3

P: n/a
Use a regular expression validator with the expression "(.|\r|\n){0,255}"
replacing the 0 and 255 with the minimum and maximum lengths that you need.


"Mark" <fi**************@umn.edu> wrote in message
news:eM**************@tk2msftngp13.phx.gbl...
To validate the length of a multiline textbox, I'm told that I have to use a regular expression validator. The regular expression below limits it to 25
characters in length, but if the user enters a hard return, it bombs
regardless of length. How do you allow hard returns in the following
regular expression? Thanks in advance!

^.{0,25}$

Mark

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.