--- title: Address Autocomplete | PostGrid description: Step-by-step guide to adding PostGrid address autocomplete to a webpage using data attributes, script tags, country filters, and callbacks. --- The best way to make sure that users are giving correct address details is to implement some form of autocomplete. In this guide, we will be walking through a quick setup for getting autocomplete going with your webpage. ## Setting up our Autocomplete In this quick start guide, we will build a functional autocomplete directly from scratch into a very a simple webpage. You may follow the headers below to navigate the steps of this process. Let’s start with a new HTML file `index.html`. Into this file, let’s insert a very basic form to receive input for the main address line, the second address line, the city, the postal/ZIP code, the state/province, and the country. ```
```  ## Getting your API Key Autocomplete with PostGrid is super quick to get going with and the first thing we will need is our API key. To access this, you will first want to head over to your dashboard and navigate to the developers sections.\ From here, you may either grab an existing key or create a new one.  Creating a new access key, we see a few options and importantly whether or not this API key will be for public use or to be used on your own server. With autocomplete to go directly onto your webpage, you will likely want a public key and to add any origins you may include autocomplete on. However, since we will be testing on a local file, we will need a server key just for testing purposes. For clarity, the only differences between a public key and a server key is really just that public keys will only work on certain origins and are prefixed by ‘live\_pk’ while server key will work everywhere and are prefixed by ‘live\_sk’. Also, you may create a test key which does not consume any lookups but only returns dummy data.\ Test keys will be prefixed by ‘test’ instead of ‘live’ as well.\ Since we only get dummy data back, I’ll be using a live key for this quick start guide.  Once we have our key, we actually find a quick step-by-step for setting up our autocomplete as well as some sample code. For this guide, we will be using the data tags and script available in these steps for how we can quickly get going with autocomplete without too much hassle.  ## Adding Autocomplete From here, it isn’t too difficult to now add autocomplete. We will start by adding to the bottom of our document the following script tag ``` ``` being sure to add in the API key grabbed from the dashboard. Next, following the outlined steps, we can add in the appropriate data tags to our form, careful not to forget `data-pg-verify` to our form tag. ``` ``` Already, we are able to test out our autocomplete by typing in to our “Address Line 1” field. As users type into the first line, you can find a list of addresses matching the supplied partial address.  Once users select one of the addresses in the list, the other fields are automatically filled out, and it is this action which consumes a lookup and not the typing.  ## Verifying Before Submission One limitation to autocomplete is often that we wish to allow users to continue to change the address after selection. This is why PostGrid’s autocomplete if often paired up with our address verification functionality.\ To enable this functionality, all we must do is add a submit button to the end of our form and the address details from the form will automatically be verified and corrected when applicable. ``` ``` If you would like to skip this automatic address verification, you can add the attribute `data-pg-skip-verification="false"` to the form tag. When verification is enabled, you will also find that the page will only refresh when an address is marked as `verified`, so it will be important to let users know any corrections they must add. ## Feedback on Verification On top of just adding any corrections, you can also add fields to provide the status of the verification as well as any applicable error messages. Let’s start by adding a generic error message field to the end as well as the status of the verification.\ To the end of our form, let’s add ```