Jump to content

Formatting International Phone Numbers


traba5058

Recommended Posts

We have a client we are building a new Marcomm Central Storefront for that has office worldwide. A few of the items that will be on the site are stationery (business cards, letterhead, envelops, etc.). The items with phone numbers need the phone numbers formatted for international numbers. Ex: +44 7891 549 692. The Phone Number Format Rule in Fusion Pro only has formats for domestic numbers.

Have any of you written a rule to format international phone numbers? If so, will you share it with me? If not, have you run into this situation before and resolved it a different way? If so, will you share that with me?

Thanks!

Link to comment
Share on other sites

This code formats numbers as you have requested. It requires that the number be 12 digits long otherwise it won't return anything.

 

var s = "447891549692";
s = s.replace(/\D/g,""); // remove anything but digits to strip out any pre-existing formatting
return (s.length == 12) ? "+" + Left(s,2) + " " + s.substring(2,6) + " " + s.substring(6,9) + " " + Right(s,3) : "";

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...