473,320 Members | 1,965 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,320 software developers and data experts.

Alpha Regex validation

Opa
Hi,

I'm trying to validate a textbox such that it only alpha
characters are accepted. I have the following Regex expression
[^a-zA-Z] exactly as shown in the RegularExpressionValidator control,
but it does not work.

Can someone help me out with this.

Thank You
Apr 7 '06 #1
7 1826
You have reversed the expression [^] in the class means you do not want
these characters. Remove ^
"Opa" <Op*@discussions.microsoft.com> wrote in message
news:22**********************************@microsof t.com...
Hi,

I'm trying to validate a textbox such that it only alpha
characters are accepted. I have the following Regex expression
[^a-zA-Z] exactly as shown in the RegularExpressionValidator control,
but it does not work.

Can someone help me out with this.

Thank You

Apr 7 '06 #2
Maybe useful to note there's a shorthand if you want to match
alphanumeric characters: "[a-zA-Z_0-9]" is equivalent to "\w" (word
characters).

Apr 7 '06 #3
Yes, but he doesn't want numeric characters.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Chris Fulstow" <ch**********@hotmail.com> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com...
Maybe useful to note there's a shorthand if you want to match
alphanumeric characters: "[a-zA-Z_0-9]" is equivalent to "\w" (word
characters).

Apr 7 '06 #4
Opa
Thanks for you reply.

I've tried setting the ValidationExpression to [a-zA-Z]
of the regular expression validator control, but it is still fails
when inputting letters only in the text box i am validating.

Any ideas?
"Chris Fulstow" wrote:
Maybe useful to note there's a shorthand if you want to match
alphanumeric characters: "[a-zA-Z_0-9]" is equivalent to "\w" (word
characters).

Apr 7 '06 #5
Hi Opa,

The pattern [a-zA-Z] will only match a single character, to match a
character string of any length, try: "[a-zA-Z]+".

Hope this helps,

Chris

Apr 7 '06 #6
Well, to be a bit more accurate, the '+' quantifier will not work with 0
characters. For a character string of *any* length (including 0), you would
use the '*' quantifier.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Chris Fulstow" <ch**********@hotmail.com> wrote in message
news:11*********************@t31g2000cwb.googlegro ups.com...
Hi Opa,

The pattern [a-zA-Z] will only match a single character, to match a
character string of any length, try: "[a-zA-Z]+".

Hope this helps,

Chris

Apr 8 '06 #7
Hi Opa,

Be careful using the "+" and "*" quantifiers to validate strings with
the RegularExpressionValidator. Although "[a-zA-Z]+" means an alpha
string with at least once character, it won't fail when the input
string is empty. This is because, by default, the
RegularExpressionValidator won't fire when there's an empty input. If
you want to disallow an empty string, use the RequiredFieldValidator
control as well.

HTH,

Chris

Apr 8 '06 #8

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

Similar topics

3
by: Alan Pretre | last post by:
Can anyone help me figure out a regex pattern for the following input example: xxx:a=b,c=d,yyy:e=f,zzz:www:g=h,i=j,l=m I would want four matches from this: 1. xxx a=b,c=d 2. yyy e=f 3....
1
by: Colin Reid | last post by:
Hey MS, here's an apparent problem in the base class library. I pulled the email validation pattern "^((*)*@(()+(*)*\.)+{2,9})" from http://regexlib.com. If I validate the email address...
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....
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...
8
by: Dooglo | last post by:
How do I check to see if my textbox has a alpha character in it? I don't want alpha characters, numeric only. Thanks Dooglo
1
by: Jim Dornbush | last post by:
Has anyone seen an updated regex expression from Microsoft for the email validation expression so that single quotes are allowed? I've been using the canned regex for emails, but recently been...
8
by: .Net Sports | last post by:
I am checking for text input on a form validation in javascript that required at least one numeric character along with any number of alpha characters for a given input text box. The below is a var...
10
by: bullockbefriending bard | last post by:
first, regex part: I am new to regexes and have come up with the following expression: ((1|),(1|)/){5}(1|),(1|) to exactly match strings which look like this: 1,2/3,4/5,6/7,8/9,10/11,12 ...
1
by: Sanders Kaufman | last post by:
I'm doing a check for only alpha-numerics, but I wanna try it with a regex. Something like this: $bReturn = is_alphanum($sString). Can somebody help me do this with regular expressions?
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.