Skip to main content

See an example here.


When you seect a country, the form autopopulates the country phone code. For example, you select Argentina and it shows “+54” automatically.

the sample URL is not working, can you please update it again.


I got this code that might help you (just edit the first 2 lines with the id of your country and phone field). The script also doesn’t let the user type any character except “+” and “0-9”, it also changes “00” to “+” when it’s typed at the beginning and it doesn’t accept spaces:


<script>
var pais = document.getElementById("pais");
var telefono = document.getElementById("telefono");

function sustituyeTelefono() {
if (telefono.value === '00') {
telefono.value = '+'
}
};

telefono.addEventListener('input', sustituyeTelefono);

function cambiaExtension() {
switch (pais.value) {
case "Colombia":
telefono.value = '+57';
break;
case "Mexico":
telefono.value = '+52';
break;
case "Argentina":
telefono.value = '+54';
break;
case "Chile":
telefono.value = '+56';
break;
case "Peru":
telefono.value = '+51';
break;
case "El Salvador":
telefono.value = '+503';
break;
case "Honduras":
telefono.value = '+504';
break;
case "Guatemala":
telefono.value = '+502';
break;
default:
telefono.value = '+';

}
};

pais.addEventListener('change', cambiaExtension);

function todoNumeros(){
var invalidMatcher = /v^0-9+]+/;
telefono.value = telefono.value.replace(invalidMatcher, '');
};

telefono.addEventListener('input', todoNumeros);


</script>


Hey @Alejandro_Urizar@Mlnfx@Alejandro_Urizar 
 

🚀 We have a brand new, complete solution for adding Country Codes and Flags to Unbounce!​​​​​​​

🆓 FREE Version:


💎 PRO Powerful Version:
👉 https://www.grooic.com/cfu-unbounce

 

👀 Check Out the Live Preview Here:

🌐 https://www.grooic.com/cfu-preview/

 

🤝 If you have any questions or need support, feel free to reach out to us on WhatsApp: 💬 +1 917 900 3111

Thanks,


Reply