> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://ajuda.greatsoftwares.com.br/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# 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.

![](https://storage.crisp.chat/users/helpdesk/website/-/a/6/a/b/a6ab90d8350d6000/add-formulario_mbca8c.png)

### 2. Configure the country code.

* Dentro del editor de páginas, haga clic en el icono del engranaje.
 
![](https://storage.crisp.chat/users/helpdesk/website/-/a/6/a/b/a6ab90d8350d6000/image_191nyfy.png)


* Next, access "**JavaScript & CSS**".
![](https://storage.crisp.chat/users/helpdesk/website/-/a/6/a/b/a6ab90d8350d6000/image_5nn7e5.png)

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

![](https://storage.crisp.chat/users/helpdesk/website/-/a/6/a/b/a6ab90d8350d6000/image_1ghh61x.png)


```
<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";](https://storage.crisp.chat/users/helpdesk/website/-/a/6/a/b/a6ab90d8350d6000/image_1vthvjg.png)
To find the correct code for other countries, you can check the full list at this link: [ISO-3166-1 Alpha-2.](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements)

### 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.

![](https://storage.crisp.chat/users/helpdesk/website/-/a/6/a/b/a6ab90d8350d6000/image_1fzll0t.png =510xauto)

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