This is a code snippet for HTML Select country code list with flags. It is based on powerful twilio's API. It is plug and play, everything is hosted on CDN. Its usage is simple, simply add this in the <head> of your web page "head" tag.
Now add this <input> tag where you wish it to be displayed
<input name="phone" type="text" id="phone"/>
and finally initialize it by this script.
var input = document.querySelector("#phone");
window.intlTelInput(input, {
separateDialCode: true
});
It should be rendered like this:
Now, there is a number of options that can be used to initialize the select dropdown.
var input = document.querySelector("#phone");
window.intlTelInput(input, {
// show dial codes too
separateDialCode: true,
// If there are some countries you want to show on the top.// here we are promoting russia and singapore.
preferredCountries: ["ru", "sg"],
//Default country
initialCountry:"sg",
// show only these countres, remove all other
onlyCountries: ["ru", "cn","pk", "sg", "my", "bd"],
// If there are some countries you want to execlde.// here we are exluding india and israel.
excludeCountries: ["in","il"]
});