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?
Use libphonenumber-js https://github.com/googlei18n/libphonenumber
It has all the required features.
Credit
http://libphonenumber.googlecode.com/svn/trunk/javascript/i18n/phonenumbers/ - perhaps this is what you are looking for, in the same library?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With