bl00mber / react-phone-input-2

:telephone_receiver: Highly customizable phone input component with auto formatting
https://bl00mber.github.io/react-phone-input-2.html
MIT License
946 stars 536 forks source link

[Bug] Formatting Broken for Puerto Rico #640

Open peter2gossell opened 1 year ago

peter2gossell commented 1 year ago

This component formats Puerto Rico phone numbers as +1 (xxx) xxx xxx xxx xx when it actually is identical to the rest of North America: +1 (xxx) xxxx-xxx. This is likely due to this website, which as far as I can tell is incorrect.

peter2gossell commented 1 year ago

A lot of other countries, especially countries that use +1 country code, are like this. This component is pretty much unusable unless you're only working with a small set of countries.

TonislavTachev commented 1 year ago

@peter2gossell Try defining a custom mask for the country code that you are mentioning in order to get the desired formatting:

                 <PhoneInput
                        masks={{ yourCountryCode: '(...) ....-...' }}
                  }/>