### [Restricting Address Autocomplete to a Specific Country](https://wpforms.com/developers/how-to-restrict-address-autocomplete-to-a-specific-country/)

**Published:** April 21, 2023
**Author:** David Ozokoye

**Excerpt:** Learn how to use JavaScript to restrict address autocomplete to a specific country. 

**Content:**

## Overview

Would you like to restrict Address Autocomplete functionality to a specific country? When you create your own unique address schemes for a desired country, you’d also want to make sure that the address autocomplete only searches in that country.

In this article, we’ll show you how to achieve this using JavaScript.

---

## Setup

For the purpose of this documentation, we’ve already created a unique address **Scheme** for Canada by [following the steps from this tutorial](https://wpforms.com/developers/create-additional-schemes-for-the-address-field/#canada "How to Create Additional Schemes for the Address Field").

Once we’ve added our additional address scheme, we’ve then selected the Scheme for our Address field inside the form builder.

![Selecting your address scheme](https://wpforms.com/wp-content/uploads/2024/12/select-scheme.png)In addition to this, we’ve also turned on **Enable Address Autocomplete** from the **Advanced** tab of the Address field.

![Enabling address autocomplete](https://wpforms.com/wp-content/uploads/2024/12/enable-address-autocomplete.png)## Adding the Snippet

Once you’ve set up and saved your form, it’s now time to add the snippet. If you need any help with adding snippets to your site, [please check out this tutorial](https://wpforms.com/developers/how-to-add-custom-php-or-javascript-for-wpforms/ "How to Add Custom PHP or JavaScript for WPForms").

```

/**
 * Restrict address autocomplete to a specific country
 *
 * @link https://wpforms.com/developers/how-to-restrict-address-autocomplete-to-a-specific-country/
 */
function wpf_dev_geo_autocomplete_default_country() {
    ?>

**Categories:** Snippets

**Tags:** Javascript, JS

---

