473,397 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Regex textbox length validator.

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
May 5 '06 #1
2 6567
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

May 5 '06 #2
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" <no*****@nowhere.com> wrote in message
news:ea****************@TK2MSFTNGP02.phx.gbl...
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

May 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mike | last post by:
I'm trying to have a form where a user has to enter a valid email address, and I'm trying to use the RegEx Validation control to do that. The problem is that when a user submits the form with a...
2
by: Hailstorm | last post by:
How can I control if "a textbox is empty or not" with regex validation? I don't want to use required field validator because I have a masked textbox control and it has "ValidationExpress" property....
1
by: Mike Moore | last post by:
Is it better to find the max length of a textbox using the dataset (database length fields) or using the length property of the textbox? Also, which is the best and easiest to do - custom...
4
by: | last post by:
Here is an interesting one. Running asp.net 2.0 beta 2. I have a regular expression used in a regex validator that works on the client side in Firefox but not in IE. Any ideas? IE always reports...
17
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher ...
2
by: JebBushell | last post by:
I see signs that the ASP.NET regular expression validator has a different instruction set that the Find utility in VS 2003. I am trying to use the VS2003 regular expression Find tool to test...
10
by: Barry L. Camp | last post by:
Hi all... hope someone can help out. Not a unique situation, but my search for a solution has not yielded what I need yet. I'm trying to come up with a regular expression for a...
8
by: =?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?= | last post by:
Hi, I need to validate a textbox to have exactly 4 characters that represent the number 0001 to 9999 (cannot be 0000). The regext I came up with rather long: ^(\d){3} | \d{2}\d | \d\d{2} |...
2
by: Mick Walker | last post by:
Hi All, I would like to know how I can limit users to only registering usernames which have alphanumberic characters and one underscore. From what I understand is I can use a regex to do this....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.