asp functions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ryan Gunn

    #1

    asp functions


    Hello. I am new to the newsgroup, and also new to JavaScript. I created
    a page that will take a users telephone number ex...612 222 2222 . Now
    I am trying to create a function that will take that number and put in
    in this format ex (612)222-2222.


    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
  • kaeli

    #2
    Re: asp functions

    In article <40d9ca01$0$164 54$c397aba@news .newsgroups.ws> ,
    gunnryan@yahoo. com enlightened us with...[color=blue]
    >
    > Hello. I am new to the newsgroup, and also new to JavaScript. I created
    > a page that will take a users telephone number ex...612 222 2222 . Now
    > I am trying to create a function that will take that number and put in
    > in this format ex (612)222-2222.
    >
    >[/color]

    Client-side javascript, server-side JScript, or server-side VBScript?

    --
    --
    ~kaeli~
    Found God? If nobody claims Him in 30 days, He's yours to
    keep.



    Comment

    • Lee

      #3
      Re: asp functions

      Ryan Gunn said:[color=blue]
      >
      >
      >Hello. I am new to the newsgroup, and also new to JavaScript. I created
      >a page that will take a users telephone number ex...612 222 2222 . Now
      >I am trying to create a function that will take that number and put in
      >in this format ex (612)222-2222.[/color]

      If you're absolutely sure that it's going to be in that format,
      then you can probably get away with:

      function formatPhone(str ){
      return str.replace(/^(\d{3}) (\d{3}) (\d{4})/,"($1)$2-$3");
      }

      But it's hard for me to imagine how you're going to be
      sure that it's in that exact format when you receive it.
      Some people might put dashes in the numbers, some may
      add the parentheses.

      If your page is on the Internet, you might even come
      across a few phone numbers like "011-52 (55) 256-0901".

      Comment

      Working...