473,398 Members | 2,188 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,398 software developers and data experts.

RegularExpressionValidator question

Hello,

Trying to setup RegularExpressionValidator to validate a textbox. I am
trying to make sure that the user enters the word Green. The case does
not matter.

However, i am totally new to Regex. Could I get some help?

Thanks.
Dec 29 '07 #1
4 1242
On 29 Dec, 20:23, Frank Rizzo <n...@none.netwrote:
Hello,

Trying to setup RegularExpressionValidator to validate a textbox. *I am
trying to make sure that the user enters the word Green. *The case does
not matter.

However, i am totally new to Regex. *Could I get some help?

Thanks.
Hi Frank

It just so happens that I too have been delving into the undergound
world of "Regular expressions" recently. My need was a bit more
complex than yours though.

I'm going to assume at this point that if you were given a patterrn
string you can do the rest. How about:

"(green)+"

when you create the Regex object there is a parameter that specifies
"ignore case". Check it out.

To decide whether it occurs or not you only need to test the "success"
property of the "match" object.

I hope I've pitched the above at the right level, let me know
otherwise.
Dec 29 '07 #2
Frank Rizzo wrote:
Hello,

Trying to setup RegularExpressionValidator to validate a textbox. I
am trying to make sure that the user enters the word Green. The case
does not matter.

However, i am totally new to Regex. Could I get some help?

Thanks.
Try ^(green)|(Green)|(GREEN)$

Don't forget to add a RequiredFieldValidator as well.
If you don't, a blank field will still be validated.

--
Riki
Dec 30 '07 #3
Frank Rizzo explained :
Hello,

Trying to setup RegularExpressionValidator to validate a textbox. I am
trying to make sure that the user enters the word Green. The case does not
matter.

However, i am totally new to Regex. Could I get some help?

Thanks.
Just a word of warning:
The validator uses client-side javascript by default, and the js-syntax
for regexes is a subset of the syntax in .Net. So be careful when you
use some regex that works in .Net in a validator.
For the main part it's the "advanced features" that are missing in js.
But in your case a "ignore case" option *is* an advanced feature.

Hans Kesting
Jan 4 '08 #4
Hello Frank,
Hello,

Trying to setup RegularExpressionValidator to validate a textbox. I
am trying to make sure that the user enters the word Green. The case
does not matter.

However, i am totally new to Regex. Could I get some help?

Thanks.
As the patterns of the regex validator are case sensitive by default and
given that there is no way to inline a case insensitivity marker, you'll
have to do the following:

^[gG][rR][eE][eE][nN]$

or (just a little shorter):

^[gG][rR][eE]{2}[nN]$

Jesse

--
Jesse Houwing
jesse.houwing at sogeti.nl
Jan 7 '08 #5

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

Similar topics

0
by: Andy Eshtry | last post by:
I have a radio button list, a textbox representing SIN or EIN based on my radio button list selection so I put 2 regularexpressionvalidator to evaluate the value of textbox. EIN must be (for...
3
by: Ricardo Corsi P. Cesar | last post by:
Hi, i looking for example in asp.net (VB) to make the RegularExpressionValidator in runtime in my code behind. I found some similars codes, but nothing in VB.. thanks!
3
by: DC | last post by:
I have this snippet: <tr> <td align="left">E-mail</td> <td> <asp:TextBox id="txtEmail" runat="server" MaxLength="100"></asp:TextBox>&nbsp; <asp:RegularExpressionValidator id="revEmail"...
0
by: Matt Morris | last post by:
Hello: I have a RegularExpressionValidator control attached to a TextBox. I have the ValidationExpression property set to a very simple validation expression (\w+). The validation always fails...
3
by: tshad | last post by:
I have a RegularExpressionValidator that doesn't seem to work correctly if you don't enter anything. In the following, it works correctly if you have at least 1 character. If you just enter...
0
by: venkat Murthy | last post by:
Hi, I have 10 regularexpression validators in my datagrid. my datagrid looks like; first5controls | boundcolumn | next5controls. Regularexpressionvalidator for first five controls works...
1
by: franz | last post by:
does anybody tell me why it doesn't works?? in any case gg beame true thanks franz Dim y As RegularExpressionValidator = New RegularExpressionValidator y.ValidationExpression =...
1
by: John Yopp | last post by:
I'm trying to use a asp:RegularExpressionValidator to validate the strength of a password. When I test the regular expression with Regex.IsMatch, it works perfectly. However, when used within a...
4
by: simonZ | last post by:
I have RegularExpressionValidator which validate one text box. When my text box is validated on client I would like to do something else. Is there some client event of RegularExpressionValidator?...
4
by: =?Utf-8?B?Y3VyaW91cw==?= | last post by:
I am using a RegularExpressionValidator to validate a TextBox. I use "^?+(\.*)?$" to check for a real number. The control works fine as long as the user enters something in the TextBox; it does not...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...

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.