initialCountry should gracefully use a default if given bad data
Currently there is a leap of faith that the value used for initialCountry will succeed in a lookup...if for whatever reason it doesn't (which seems like a possibility since that value is coming from a 3rd party service like ipinfo or perhaps from existing data in the application) then initialization will fail.
I suggest taking a more defensive approach to handle this possibility and default to the preferred country.
Steps to reproduce
- Initialize with an unsupported value in the
initialCountryparameter
window.intlTelInput(input, {
utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.13/js/utils.min.js",
initialCountry: 'baddata',
preferredCountries: ["us"],
});
Expected behaviour
A defensive approach that catches this condition and uses the default / preferred country value, but still initializes the UI
Actual behaviour
JavaScript exception and the form element is unusable

Yeah that would make sense, thanks for raising. I'd be open to a PR.
Is there a way to have intlTelInput country flag set to empty and force the user to select their country code ?
@tech-thanoshotels no this is not currently possible, and would be too much work to implement - I'm not interested in adding this functionality for the time being.
There's a fix for this in master, which will be included in the next release (soon).