Connecting Tech Pros Worldwide Forums | Help | Site Map

Regular Expression for multiline validation

Mark
Guest
 
Posts: n/a
#1: Nov 17 '05
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



Sonali.NET[MVP]
Guest
 
Posts: n/a
#2: Nov 17 '05

re: Regular Expression for multiline validation


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

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



"Mark" <field027_nospam_@umn.edu> wrote in message news:eMrfWiqWDHA.2880@tk2msftngp13.phx.gbl...[color=blue]
> 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
>
> [/color]

S. Justin Gengo
Guest
 
Posts: n/a
#3: Nov 17 '05

re: Regular Expression for multiline validation


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" <field027_nospam_@umn.edu> wrote in message
news:eszTJArWDHA.2328@TK2MSFTNGP12.phx.gbl...[color=blue]
> That looks great for server side validation, but what about client side?
> Thanks.
>
> Mark
>
> "Sonali.NET[MVP]" <xb_sonalix@hotmail.com> wrote in message
> news:ug9Nq9qWDHA.2352@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" <field027_nospam_@umn.edu> wrote in message
> news:eMrfWiqWDHA.2880@tk2msftngp13.phx.gbl...[color=green]
> > To validate the length of a multiline textbox, I'm told that I have to[/color][/color]
use[color=blue]
> a[color=green]
> > regular expression validator. The regular expression below limits it to[/color][/color]
25[color=blue][color=green]
> > 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
> >
> >[/color]
>
>[/color]


Eric
Guest
 
Posts: n/a
#4: Nov 17 '05

re: Regular Expression for multiline validation


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" <field027_nospam_@umn.edu> wrote in message
news:eMrfWiqWDHA.2880@tk2msftngp13.phx.gbl...[color=blue]
> To validate the length of a multiline textbox, I'm told that I have to use[/color]
a[color=blue]
> 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
>
>[/color]


Closed Thread