Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > problems with the regular expression validator on the client

Reply
Thread Tools

problems with the regular expression validator on the client

 
 
Chris Barrow
Guest
Posts: n/a
 
      10-23-2003
Hi Everyone,

I am using a regular expression validator control in a web
form. I essentially want the control to pattern match
whether or not a user has enter non-digit characters into
a text field. Here is the control syntax along with the
reg expression:

<asp:regularexpressionvalidator id="rxvCity"
runat="server" controltovalidate="txtCity" display="None"
validationexpression="[^0-9]" errormessage="City field
cannot contain numeric characters"/>

Problem: the expression doesn't seem to validate. No
matter what I type into the text field, the errormessage
is always returned. Is there something wrong here with my
syntax for the reg expression? I have also tried "\D" but
that doesn't seem to work either. Curiously, another reg
validator control that uses the expression: "\d{3}-\d{3}-\d
{4}" works just fine.

If anyone has an idea on why this is happening, I would
greatly appreciate it.

Thanks,

Chris...
 
Reply With Quote
 
 
 
 
Axel Dahmen
Guest
Posts: n/a
 
      10-23-2003
Hi, Chris,

your expression expects *one single* character as input to validate is as
true. Add the "+" sign in order to validate "one or more" none digit values:
"[^0-9]+"

HTH,
Axel Dahmen

-------------------------------------------
"Chris Barrow" <(E-Mail Removed)> schrieb im Newsbeitrag
news:390b01c39965$3c400100$(E-Mail Removed)...
> Hi Everyone,
>
> I am using a regular expression validator control in a web
> form. I essentially want the control to pattern match
> whether or not a user has enter non-digit characters into
> a text field. Here is the control syntax along with the
> reg expression:
>
> <asp:regularexpressionvalidator id="rxvCity"
> runat="server" controltovalidate="txtCity" display="None"
> validationexpression="[^0-9]" errormessage="City field
> cannot contain numeric characters"/>
>
> Problem: the expression doesn't seem to validate. No
> matter what I type into the text field, the errormessage
> is always returned. Is there something wrong here with my
> syntax for the reg expression? I have also tried "\D" but
> that doesn't seem to work either. Curiously, another reg
> validator control that uses the expression: "\d{3}-\d{3}-\d
> {4}" works just fine.
>
> If anyone has an idea on why this is happening, I would
> greatly appreciate it.
>
> Thanks,
>
> Chris...



 
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 On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression Validator seems to be wrong! Edward ASP .Net 0 12-04-2003 05:31 PM
P.O. Box Regular Expression Validator - heeeeeelp? Simple Simon ASP .Net 2 11-04-2003 05:10 PM
Regular Expression Validator Bryce Budd ASP .Net 1 09-18-2003 05:51 PM
Dynamically changing the regular expression of Regular Expression validator VSK ASP .Net 2 08-24-2003 02:47 PM
Re: howto use c# regular expression validator to exclude file types Brian Vallelunga ASP .Net 2 07-31-2003 10:27 PM



Advertisments