Results 1 to 3 of 3

Thread: Restrict phone number to accept only numbers, dashes, plus sign and bracket

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2006
    Posts
    120

    Restrict phone number to accept only numbers, dashes, plus sign and bracket

    i have a text box for user to key in the phone number. I want restrict that textbox to accept only the numbers, dashes, plus sign and bracket. Please advise if this is possible.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Restrict phone number to accept only numbers, dashes, plus sign and bracket

    It's possible in a few ways. You can have a javascript method that gets called whenever the textbox's text changes, this method can look for and remove any of the characters that aren't in a predetermined set.

    You can use a RegularExpressionValidator in ASP.NET that specifies a regex that would match a valid phone number and have it validate both on client side and codebehind.

  3. #3
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Restrict phone number to accept only numbers, dashes, plus sign and bracket

    You could also jump into AJAX and use its' masked text boxes.. pretty slick stuff, that AJAX.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width