1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

RegEx

Discussion in 'Software Development' started by Doomsday123, Jan 23, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. Doomsday123

    Doomsday123 Thread Starter

    Joined:
    Jul 1, 2002
    Messages:
    505
    Im trying to do a asp:regularexpressionvalidator and what I want it to do is pnly accept number 0-9 in the textbox. I dont want any special characters, any letters, any commas or periods, or anything else. just numbers 0-9. Should be fairly simple i think but I am horrible at regular expressions. Any help would be great. Thanks.
     
  2. cristobal03

    cristobal03

    Joined:
    Aug 5, 2005
    Messages:
    3,086
    Is there a length limit on the string?

    chris.
     
  3. Doomsday123

    Doomsday123 Thread Starter

    Joined:
    Jul 1, 2002
    Messages:
    505
    yeah, it should be 6 digits
     
  4. cristobal03

    cristobal03

    Joined:
    Aug 5, 2005
    Messages:
    3,086
    I believe the regular expression code for six digits is

    "\d{6}"

    So, if the input didn't match that, you could erase it and prompt the user for digit-only input. I have a feeling that doesn't answer your question...

    If not, could you be a bit more specific as to what you're after?

    chris.
     
  5. Doomsday123

    Doomsday123 Thread Starter

    Joined:
    Jul 1, 2002
    Messages:
    505
    Thats almost it. It needs to be 6 digits or less. So if someone wants to put in 300 it will still work. On that one you would have to put 000300 to make it work.
     
  6. cristobal03

    cristobal03

    Joined:
    Aug 5, 2005
    Messages:
    3,086
    Ah...I see. Hmm, I'm not great at it either. How about this?

    "?\d{0,6}"

    I can't really test these because I don't have an environment that handles regex, sorry.

    chris.
     
  7. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/436533

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice