I've installed the plugin and Its displaying the countries correctly and working fine, but when I submit the form that has the input of type = "tel", the form does not submit the country code, I don't know how this works, but I did read all of instructions in https://github.com/jackocnr/intl-tel-input page, but I didn't understand how to get the full number + code country together so I can insert them into MySQL data base.
I'm so beginner, and just confused how to get this to work fine. Sorry if the question is not that hard, but I really don't know how this works.
The jQuery code I have:-
$("#telephone").intlTelInput({
initialCountry: "sd",
separateDialCode: true
});
$(".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. – Republicanize$("#telephone").on("blur", function(){ $(this).val("+" + $(".country[class*='active']").attr("data-dial-code") + $(this).val()); });
. If someone goes back to this field again and then leaves it (with or without editing), then it will once again cause the country code to be appended. – Republicanizeif($(this).val() == '') { // code }
– Hamulus