Loading...

JavaScript - Typeahead

Improve the user experience by supplying a list of possible choices. Try it

Examples

Install from NPM or CDN

npm install getaddress-typeahead
<script src="https://cdn.getaddress.io/scripts/getaddress-typeahead-1.1.0.min.js"></script>

Usage

<label>Postcode</label>
<input id="textbox_id" type="text">

<script>
    getAddress.typeahead(
        /*id:*/'textbox_id',
        /*search_on:*/ 'postcode',
        /*api_key:*/ 'API Key or Domain Token' 
    );
</script>

Options

getAddress.typeahead(
     element_id:   /* The id of the HTML input element' */,
     search_on:  /*'postcode'|'locality'|'town_or_city'|'district'|'county'|'country'*/,
     api_key: 'API Key' /*API key or Domain Token*/
    }
);

Domain Tokens

To avoid exposing your API key in browser code, Domain Tokens can used in place of your API key.
Domain Tokens can be generated for a specific domain and it's sub-domains. They can also limit the number of look-ups per minute for an IP address.

<script>
    getAddress.typeahead
    (
     'textbox_id',
     'postcode',
     'dtoken_hEDzcyiWMI1eXXXX'
    );
</script>
Top