jackocnr / intl-tel-input

A JavaScript plugin for entering and validating international telephone numbers. React and Vue components also included.
https://intl-tel-input.com
MIT License
7.69k stars 1.95k forks source link

Select country from dialCode #1826

Closed Hector-Machado closed 1 month ago

Hector-Machado commented 1 month ago

I want to select country from dialCode.

Because I receive the dialCode value, saved in the database and when I want to access that input again I need it to be selected with the option that the user selected when they created their phone number, but I have the dialCode, I would have to transform the dialcode in country code to work?

jackocnr commented 1 month ago

Please see the Recommended Usage section of the readme - we recommend you DO NOT store the country/dial code separate to the phone number. We recommend you just save one string to your database, and that is the number in full international format. Then when you initialise the plugin on an input containing that full intl number, it will automatically select the right country and re-format the number appropriately (according to whichever initialisation options you use). Does that make sense?

jackocnr commented 1 month ago

Closing due to inactivity.