Monday, May 20, 2024
6
rated 0 times [  8] [ 2]  / answers: 1 / hits: 21638  / 11 Years ago, thu, october 24, 2013, 12:00:00

I have a database with phone numbers which I would like to format according to the country code of the phone number.



The numbers are currently stored in the following format:



+[country_code][number] (like +4512345678)


What I need is some kind of library for javascript, that based on the country code can format the number according to the official national format (http://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers). Below are some examples of how some of the numbers could be formatted



+4512345678 => +45 12 34 56 78
+12892708970 => (289) 270-8970


I have found this Java-library here https://code.google.com/p/libphonenumber/, which bascially solves the problem. However I would like a simple Javascript-solution, which they actually demonstrate on their page, but I cannot find any official downloads to the file file they use, making me wonder if a better solution exists?


More From » number-formatting

 Answers
45

Use libphonenumber-js https://github.com/googlei18n/libphonenumber



It has all the required features.



Credit


[#74769] Wednesday, October 23, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
myrap

Total Points: 407
Total Questions: 105
Total Answers: 109

Location: Cambodia
Member since Thu, Oct 7, 2021
3 Years ago
myrap questions
Tue, Feb 8, 22, 00:00, 2 Years ago
Wed, Jan 15, 20, 00:00, 4 Years ago
Thu, Oct 24, 19, 00:00, 5 Years ago
Thu, Oct 3, 19, 00:00, 5 Years ago
Mon, Aug 12, 19, 00:00, 5 Years ago
;