intl-tel-input icon indicating copy to clipboard operation
intl-tel-input copied to clipboard

Inconsistent behaviour

Open espen opened this issue 1 month ago • 1 comments

I am trying to use getNumber but it is only working on the initial call. To reproduce:

  1. go to https://intl-tel-input.com/examples/strict-mode.html
  2. enter phone code in international format
  3. Run intlTelInput(document.getElementById('phone')).getNumber(intlTelInput.utils.numberFormat.E164) in the console. It returns correctly however the displayed value in the input changes.
  4. Run command again. It returns national phone number.

espen avatar Nov 14 '25 14:11 espen

In addition intlTelInput(document.getElementById('phone')).getValidationError(); will then give 1 as an error after executing getNumber().

espen avatar Nov 14 '25 14:11 espen

When you run intlTelInput(document.getElementById('phone')).getNumber(intlTelInput.utils.numberFormat.E164) you are initialising the plugin on an input where the plugin is already initialised - you shouldn't do this. Instead you should be using the instance variable to run getNumber. In your own code, this would be:

const iti = intlTelInput(input);
iti.getNumber();

But if you want to do something similar on the demo site, you don't have direct access to the instance variable, so instead you can find it with something like this:

const iti = intlTelInput.instances[0];
iti.getNumber();

jackocnr avatar Dec 12 '25 08:12 jackocnr

Thanks for the explanation!

espen avatar Dec 12 '25 10:12 espen