Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Regex textbox length validator.

Reply
Thread Tools

Regex textbox length validator.

 
 
darrel
Guest
Posts: n/a
 
      05-05-2006
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


 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?G=F6ran_Andersson?=
Guest
Posts: n/a
 
      05-05-2006
The ^ and $ shouldn't be used in a RegularExpressionValidator. The space
in the quantifier might be a problem also.

[\S\s]{1,50}

darrel wrote:
> 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

 
Reply With Quote
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      05-06-2006
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!
*************************************************
"darrel" <> wrote in message
news:eaN5%...
> 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Smart or stupid? Tying textbox length to database column length Dan Manes ASP .Net 1 04-23-2006 10:57 PM
Is ASP Validator Regex Engine Same As VS2003 Find Regex Engine? =?Utf-8?B?SmViQnVzaGVsbA==?= ASP .Net 2 10-22-2005 02:43 PM
Is Validator Regex Same as VS 2003? =?Utf-8?B?SmViQnVzaGVsbA==?= ASP .Net 2 10-22-2005 10:27 AM
Re: Validator control for text length moondaddy ASP .Net 1 02-28-2004 09:15 AM
Checking string's length with validator controls Pierre ASP .Net 2 10-26-2003 10:34 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57