Phone number formatting

June 10th, 2007

Phone number formatting has always been a difficult one. Learn how you can enforce some simple formatting rules using a matching pattern.

The difficulty arises from the fact that almost every brand or business has its own formatting rules, sometimes reasonable, sometimes outright weird.
You can use this 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

See also:
    None Found

2 Responses to “Phone number formatting”

  1. Don Says:

    Common US Pattern for phone numbers:
    Pattern: (###) ###-####
    Input: 555-555-1212
    Output: (555) 555-1212

  2. Don2 Says:

    This feature is no longer found under Edit Fields! After a recent update, it has been moved.

    You need to log in as a designer, then click on test order. The field names will appear and you can click on any field name to bring up the field editor. Use that editor feature to set values for fields so that you can create drop downs, to set required lengths, upper or lower case restraints, or to set masking like you do for a phone number.

    You can now click on fields and change field names apparently as well after this update.

Leave a Reply

You must be logged in to post a comment.