473,785 Members | 2,449 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6580
The ^ and $ shouldn't be used in a RegularExpressi onValidator. 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
ValidationExpre ssion="[\S\s]{10,50}"

Can also be

ValidationExpre ssion="[\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*****@nowher e.com> wrote in message
news:ea******** ********@TK2MSF TNGP02.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
1954
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 blank line, it is ACCEPTED even though it does not pass the pattern match in the expression. Another problem is that if there are leading spaces or trailing in a valid email address, the expression fails. Case 1:(blank) : ...
2
1580
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. For example, if I want to control if it's a time value, I use "(()|())()" but it doesn't work when textbox is empty. How can I solve this problem? I want user to fill this area. And by the way, if I try to use a req field validator for this, my...
1
1515
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 validator or expression validator for max and min length of textbox fields?
4
1365
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 the field is invalid. The expression is: ^(?!\d)(?=.*\d)(?=.*)(?=.*)(?=.*).{8,25}$ If I enter "Test_Field1" Firefox considers it valid on client side, IE doesnt. Server side considers it valid too because when I submit the form in
17
3980
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 http://forta.com/books/0672325667/
2
1495
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 regular expressions for use in a ASP.NET validator. The results I am getting are inconsistent . What works in VS does not always work in ASP.NET and vice versa. For example: +({0,1})(*)
10
3115
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 RegularExpressionValidator that will allow certain HTML tags: <a>, <b>, <blockquote>, <br>, <i>, <img>, <li>, <ol>, <p>, <quote>, <ul>
8
7662
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} | \d{3}$ and not easilily extendable should the need arise for say 5 or 6 numbered text.
2
1564
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. But I have no idea how to do it. I have only used a customfieldvalidor before. And the reason I cant do it now is because of the design of the page itself. So basically I need to know how, upon a button click, I can compare the text entered in a...
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9950
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.