intlTelInput is not a function
See original GitHub issueHello, I know this issue has been reported many times but none of the answers have been able to fix my problem.
Steps to reproduce
Same as the Github ones, both css and js imports (that is the right path):
<link rel="stylesheet" href="./node_modules/intl-tel-input/src/css/intlTelInput.css">
<script src="./node_modules/intl-tel-input/src/js/utils.js"></script>
My input is generated dynamically with a ‘tel’ type
I then check the type and execute the following code:
if (columnData.forminfo.fields[u].inputtype === "tel") { var input = $("#"+columnData.forminfo.fields[u].inputid); window.intlTelInput(input); }
But I also tried this (with the utils import too):
var input = document.querySelector("#"+columnData.forminfo.fields[u].inputid); var iti = intlTelInput(input, { utilsScript: "https://cdn.jsdelivr.net/npm/intl-tel-input@16.0.3/build/js/utils.js", }); }
Expected behaviour
I should have had my input created with the flag version.
Actual behaviour
I get an error: ‘intlTelInput is not a function’.
Initialisation options
I put my code above.
If I don’t use the window. in the first code, I get a ‘intlTelInput is not defined’ if it can help.
Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Comments:19 (6 by maintainers)
Top Related StackOverflow Question
I’m sorry but if you’re having problems with basic JavaScript operations like selecting an element, then I don’t have time to provide support for that - I would recommend you ask on StackOverflow. best of luck.
The error in my case was that I’d copied the wrong JavaScript files from the release zip file into my project - I’d copied from the src folder instead of the build folder.
Check that the intlTelInput.js linked to from your page starts with a header like this, rather than pure JS code:
Even the minified version has this header. Hope this helps someone.