question

dl-mozart46 avatar image
dl-mozart46 asked anton-nikitin answered

Good JS code for normalizing phone numbers into E164 format?

I'm writing an app where users are asked to input a phone number to send SMS to.  I'd like to store that number in a standard format like E164, without the suer having to type in dashes, brackets, and country codes.  Is there a piece of JS code that someone can share?  Thanks.
topic-default
1 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

·
anton-nikitin avatar image
anton-nikitin answered
There are two options I know of.

1. Use Google libphonenumber ( https://github.com/googlei18n/libphonenumber) - it has JS port.

2. RingCentral has an API to parse/format phone numbers. But it will require you to send request to server every time you need E.164 number from user input. If you want to explore this option I can share documentation with you.
1 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.