Articles on: Page Editor

How to add the COUNTRY CODE TO THE PHONE FIELD of the Form (via code)

1. Add the form to the page


  • In the top left corner, click the Adicionar elementos icon and select the form. Include the phone field, validated as an international phone number. You can set it as required if you wish.



2. Configure the country code.


  • Dentro del editor de páginas, haga clic en el icono del engranaje.




  • Next, access "JavaScript & CSS".


  • Click "Add code" and add the code below with the code type "Functionality."




<script>
const DDI = "br";

function changeDDI() {

let forms = $('.gpc-e.e_formulario');

if (forms.length > 0) {

forms.each(function(index, form) {

let id_form = $(form).attr('id');
let campoDDI = $(form).find('.telefone_ddi');

if (campoDDI.length > 0) {

campoDDI.each(function(index, campo) {

let campoId = $(campo).attr('id');
let key = '#' + id_form + '#' + campoId;

try {

if (
typeof phoneMaskGreat !== 'undefined' &&
phoneMaskGreat[key]
) {
phoneMaskGreat[key]._setCountry(DDI);
}

} catch (err) {}

});

}

});

}

}

changeDDI();

$('body').on('click', '.link_popup', function(e){

setTimeout(function(){
changeDDI();
}, 499);

});
</script>


3 . Set the country's initial code


On the first line of the code, you must define the desired country using the two-digit ISO-3166 code standard. For example, for Brazil the code is "pt". Just replace the value on the line below:


Example for Portugal: "PT";

To find the correct code for other countries, you can check the full list at this link: ISO-3166-1 Alpha-2.


All set!

With this code, the phone field on your form will now display the configured country code and will work properly for different countries.



If you still have questions, don't hesitate to reach out to our support team!

Updated on: 08/08/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!