I am trying to get value with the country code. https://www.jqueryscript.net/form/jQuery-International-Telephone-Input-With-Flags-Dial-Codes.html I am following this.
But I am not able to achieve the functionality of how to get the value with country code.
Suppose my input element is this.
<input type="phone_number" name="phone_no" value="" placeholder="Phone No" class="input form-control" autocomplete="off">
I did initialize the plugin
(async () => {
let phoneNumberField = $('input[type=phone_number]');
let isPhoneNumberFieldExist = phoneNumberField.length;
if (isPhoneNumberFieldExist) {
phoneNumberField.intlTelInput({
});
}
})();
Now while I am submitting the form I am receiving the above telephone number element too.
console.log(el); //will log the same above element
console.log(el.value) // will log the number in input box
But I am not able to get value with the country code. I tried using instance variable like given in the linked guide. also tried using this
console.log( $(el).intlTelInput().getNumber());
But Nothing seems to work. Can any help me with how to get value with the country code?