Phone number formatting

04/06/2007

Phone number formatting has always been a difficult one with some designs requiring strict compliance with formatting guidelines.
The problem is that every brand or business has its own formatting rules, sometimes reasonable, sometimes outright weird.
You can use our new feature to specify the rules exactly the way you want regardless of what the users enter.

Formatting pattern by example

Pattern: ###-##-##
Input: 321 09-33
Output: 321-09-33

Pattern: ###.##.##
Input: 321 09-33
Output: 321.09.33

Pattern: ### . ## . ##
Input: 321 09-33
Output: 321 . 09 . 33

Pattern: (###) ### ## ##
Input: 821-321 09-33
Output: (821) 321 09 33

Formatting logic

The system applies the following logic to the formatting process:
1. Take user input and strip off any separators (spaces, hyphens, dots, commas, etc)
2. Stop formatting if any letters are encountered. E.g. 0800-call-4-help will not be formatted, but a warning will be raised and recorded in the order details
3. Match numbers entered by the user to #(pound sign or hash) and fit any other characters from the formatting string in their respective places.
4. Stop formatting, raise an warning and record it in the order details if there are more or less numbers in the user input than #’s in the formatting string.

Where to find this feature

Formatting patterns can be entered into the same screen as other field constraints. Click in Edit fields in the template menu.

phone-formatting.png

Leave a Reply