Closed HKallaste closed 3 weeks ago
Sorry I don't understand the issue.
Following your instructions, on the demo site I just did the following in the console:
const iti = window.intlTelInput.instances[0];
iti.setNumber("+17021231234");
document.querySelector("#phone").value = "123"
iti.setNumber("+447947123123");
After the first setNumber
, the selected country correctly changes to US. Then after the 2nd setNumber
, the selected country correctly changes to UK. So I don't understand the problem. Please can you provide steps to reproduce, being more specific about exactly what values to use to reproduce the issue.
If the second number is missing the country code, there isn't a case for returning to the default. e.g. iti.setNumber("7947123123");
As of the latest version, v23.0.12, you should be able to call setCountry()
(passing no argument) to reset it to the globe icon. Let me know if you have any other issues.
Plugin version
v23.0.4
Steps to reproduce
Expected behaviour
If there is a valid country code: it'll pick out the country for it, if not: then it would reset to the default
Actual behaviour
If you first open a number that lacks the code, it'll stay as default as intended. If you open a number that has the code, and after open one without it - the country will still be set to the previous number's country after the format.
Initialisation options
countryOrder: ["ee", "fi", "se", "no", "dk", "de", "gb"], countrySearch: false, utilsScript: "https://cdn.jsdelivr.net/npm/intl-tel-input@23.0.4/build/js/utils.js", nationalMode: false, (added due to the leading 0 causing issues)