• Hello!

    I have a CF7 form on my site that has a phone number field. If someone enters all of the numbers in succession without any spaces, hyphens or parentheses, it will output the number as just a string of numbers.

    I am looking for a way to format the output of the numbers so that there will be spaces and hyphens – so that it will look like a real phone number when it gets outputted.

    We are only dealing with customers in the US, so we don’t need to format any other type of number than ### – ### – ####.

    How can I go about doing this?

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Thread Starter pederweb

    (@pederweb)

    Thanks very much! I was able to place the code in my functions.php file (assuming that’s where it goes) and it worked.

    I need to take the next step, though. This code puts a comma after every three digits. I’m wondering how I would make the output to have dashes and spaces to look like a phone number. Or, for example, just have spaces ever certain amount of numbers, say for example, like a credit card. If they put in 16 consecutive digits, how can I get the mail output to give me four groups of four digits with spaces between each?

    Thanks!

    Thread Starter pederweb

    (@pederweb)

    Sorry, had a typo. That should say “every certain amount of numbers.”

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to format phone number output’ is closed to new replies.