IntlPhoneNumber(inputCtrlId) { const input = document.querySelector(inputCtrlId); const phoneInput = window.intlTelInput(input, { initialCountry: "auto", strictMode: true, nationalMode: true, geoIpLookup: callback => { fetch("https://ipapi.co/json") .then(res => res.json()) .then(data => callback(data.country_code)) .catch(() => callback("us")); }, utilsScript: "https://cdn.jsdelivr.net/npm/intl-tel-input@19.5.3/build/js/utils.js" // just for formatting/placeholders etc }); return phoneInput;
<input type="tel" id="PhoneNumber" placeholder="Enter Phone Number" required />
$("#PhoneNumber").val(IntlPhoneNumber("#PhoneNumber").getNumber()); $("#PhoneNumber").val("+913333333333");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)