I have an HTML form using intl-tel-input for automatic country detection based on the IP.
I am trying to send the values of the form, but I am getting in Google sheets only the phone number without prefix
<form>
<input type="text" name="first_name" placeholder="First Name">
<input name="phone" type="tel" id="phone" placeholder="phone Number">
<input type="hidden" id="country" name="country">
</form>
this is the JS code
var input = document.querySelector("#phone");
// window.intlTelInput(input, {
// // any initialisation options go here
// });
var iti = intlTelInput(input, {
initialCountry: "auto",
geoIpLookup: function(success, failure) {
$.get("https://ipinfo.io", function() {}, "jsonp").always(function(resp) {
var countryCode = (resp && resp.country) ? resp.country : "";
success(countryCode);
});
},
});
var country = $('#country');
var iti = intlTelInput(input.get(0))
// listen to the telephone input for changes
input.on('countrychange', function(e) {
// change the hidden input value to the selected country code
country.val(iti.getSelectedCountryData().iso2);
});
Does Google sheets accepts input from hidden fields?
There is any way that I can get the country code separated or at least the full number (country_code+phone_number)
Thank in advance.