Phone Numbers Formatting

Modified on Thu, 15 Feb 2024 at 10:31 AM

It's possible to enforce shopper-entered phone number formatting, using one of two methods:

  • The existing phone number masking (Configuration - Settings - PhoneNumberMask.Enabled) has been improved to allow the United States and International phone number entry to be modified to provide the best format for your store needs.
  • A new setting ForcePhoneFormat.Enabled allows for explicit restrictions on the phone number field in the Account and Address pages, preventing a shopper from saving the entry unless they provide a phone number in the correct format.


Configuration - Settings:

 ForcePhoneFormat.EnabledIf true, phone numbers will be constrained to the format specified by ForcePhoneFormat.Pattern. Please set a value on ForcePhoneFormat.Pattern BEFORE enabling this setting. It is STRONGLY RECOMMENDED that string resource phone.forcedformatinvalid is updated to provide the expected phone format to the shopper if they enter an invalid format.  true / false 
 ForcePhoneFormat.PatternIf ForcePhoneFormat.Enabled is TRUE, the selected regular expression pattern here will be used to verify the phone format. If the pattern does not match, string resource phone.forcedformatinvalid will be displayed to the shopper. It is STRONGLY RECOMMENDED that string resource phone.forcedformatinvalid is updated to provide the expected phone format to the shopper if they enter an invalid format. 

USA DOMESTIC (555) 555-5555 :
\(\d\d\d\)\s\d\d\d-\d\d\d\d

USA INTERNATIONAL +1-555-555-5555 :
\+1-\d\d\d-\d\d\d-\d\d\d\d

 PhoneNumberMask.Enabled If true, customer-entered phone numbers will be forced to adhere to a standard format, for example "(000) 000-0000". The PhoneNumberMask.USA setting is used for USA numbers, while PhoneNumberMask.International is used for international numbers. The customer phone number entered on the account page also uses PhoneNumberMask.International.  true / false
 PhoneNumberMask.USA If PhoneNumberMask.Enabled setting is true, US phone numbers will adhere to the format specified in this setting. It is recommended to use the default value: (000) 000-0000 XXXXXXXXXX (000) 000-0000 XXXXXXXXXX
 PhoneNumberMask.International If PhoneNumberMask.Enabled setting is true, International (non-US) phone numbers will adhere to the format specified in this setting. It is recommended to use the default value: XXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXX


SETUP EXAMPLES:

- To enforce and assist the format of the standard United States 10-digit (aaa) bbb-cccc

    PhoneNumberMask.Enabled      TRUE

    PhoneNumberMask.USA              (000) 000-0000

    PhoneNumberMask.International  (000) 000-0000


NOTE:  ForcePhoneFormat.Enabled must be FALSE


- To enforce and assist the format of the standard United States 10-digit (aaa) bbb-cccc PLUS allow entry of an Extension number (ex. (123) 456-7890 ext 212):

    PhoneNumberMask.Enabled      TRUE

    PhoneNumberMask.USA              (000) 000-0000 XXXXXXXXXX

    PhoneNumberMask.International  (000) 000-0000 XXXXXXXXXX


NOTE: ForcePhoneFormat.Enabled must be FALSE


In the Settings, if you added additional TEXT spaces to the number format, it will look for "ext ####" , but nothing else is allowed. You would use something like this:

(000) 000-0000 XXX XXXX

- "0" are required numerical entries.
- "( -" and other special characters will be added automatically as the customer enters values.
- "XX" are optional entry slots. Though alphas can be entered, ONLY "ext" (or "EXT") and numeric values will be accepted.
- " " Spaces will be automatically added as the customer types entries beyond the space.

NOTE: Content > Manage Prompts > account.phone.example and address.phone.example should be adjusted to match your format.


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article