I am using the demo code for intlTelInput provided here
I am able to get the dial code using following
var intlNumber = $("#phone").intlTelInput("getSelectedCountryData");
But i am not able to get the full number i.e. "dialcode + number entered by user" from the #phone text box.
You can use intlTelInput('getSelectedCountryData'). dialCode to get country code selected from dropdown. stackoverflow.com/questions/46664571/… Thanks, I found the answer in this.
country[class*='active']"). attr("data-dial-code") should give you the dial code for the country that's been selected. You'll have to pass that variable manually using submit then. Or append before the string the value obtained here to the telephone number being sent to PHP.
Use the getnumber
option, so in your case:
var intlNumber = $("#phone").intlTelInput("getNumber");
^ This will give you the entire number (country code + phone number)
See docs here.
You have to use the built-in methods for getting the full number but you must add the utilsScript
$("#phone").intlTelInput(
{
//Other configurations,
//Other configurations,
utilsScript : "/path/to/build/utils.js",
});
in the initialization for the intlTelInput as stated here Intl-Tel-Phone Docs
and then you can get the full number by using
$("#YourInputElementID").intlTelInput("getNumber");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With