Standardizing Phone Numbers – Input Field or Display them in a Standard Format

This topic contains 3 replies, has 4 voices, and was last updated by  Alex Rollin 5 years ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #484245

    Christopher Kemmett
    Free User
    Post count: 3

    I would like my listings phone numbers to appear in a standard format.

    (country code)-(area code)-(first 3)-(last four)
    ie. 1-800-555-5555

    I feel like the input field should just require the standard format. This would solve the problem at its beginning, the user input.

    I understand every country has a different format, and every geodirectory user could have a different preference. This is more of a custom preference, not some development issue.

    I found two pages on this topic, but no solution is mentioned besides needing “customization”.

    The below post mentions the issue of the input field accepting characters that are not numbers, but no solution.
    https://wpgeodirectory.com/support/topic/phone-number-2/

    This post has a solution that only allows input of ‘numbers’.
    https://wpgeodirectory.com/support/topic/formatting-phone-numbers/

    Some companies may have vanity phone numbers. One of my companies does, as well. So restricting the input to numbers is not a concern for us. We just want to add the dashes (-) where necessary and enforce the country code. Our site is primarily USA for now, but hope to expand globally.

    I think a page specific code snippet would be best, targeting the phone input field on the add listing page.

    If not that then maybe a front-end code snippet targeting the phone field would fix this, however not every user will use a country code, and some may post with parenthesis creating other issues, and making the amount of code needed larger.

    #484254

    Kor
    Moderator
    Post count: 16516

    Hi Christopher,

    Thanks for your post. Achieving what you needed there would require customization. But I’m going to forward this to a developer for a second opinion.

    #484323

    Guust
    Moderator
    Post count: 29970

    You can use the validation pattern setting, see image.
    http://regexlib.com/Search.aspx?k=phone+number

    Thanks

    #484370

    Alex Rollin
    Moderator
    Post count: 27815
Viewing 4 posts - 1 through 4 (of 4 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket