problems with the regular expression validator on the client

Discussion in 'ASP .Net Web Controls' started by Chris Barrow, Oct 23, 2003.

  1. Chris Barrow

    Chris Barrow Guest

    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...
     
    Chris Barrow, Oct 23, 2003
    #1
    1. Advertising

  2. Chris Barrow

    Axel Dahmen Guest

    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" <> schrieb im Newsbeitrag
    news:390b01c39965$3c400100$...
    > 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...
     
    Axel Dahmen, Oct 23, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Vallelunga
    Replies:
    2
    Views:
    8,294
    Brian Vallelunga
    Jul 31, 2003
  2. VSK
    Replies:
    2
    Views:
    2,298
  3. Bryce Budd

    Regular Expression Validator

    Bryce Budd, Sep 18, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    576
    Brian Davis
    Sep 18, 2003
  4. Simple Simon
    Replies:
    2
    Views:
    4,347
    Simple Simon
    Nov 4, 2003
  5. Edward
    Replies:
    0
    Views:
    830
    Edward
    Dec 4, 2003
Loading...

Share This Page