Google API: Google Place Autocomplete for Postal (Zip) Code using JavaScript

Last Reply 6 months ago By dharmendr

Posted 6 months ago

using this API can we make auto complete extender, so in textbox if user type zipcode it shows city, and if user type initial of city it also shows city.

i want whether i type zipcode or city name in textbox it populates city name in textbox.

Posted 6 months ago

Hi nauna,

Displaying city name not possible.

But based on zipcode or city name you can populate the address.

Refer below sample code.


<script type="text/javascript" src=""></script>
<script type="text/javascript">
    window.onload = function () {
        var postal = document.getElementById('postalCode');
        var options = { types: ['(regions)'] }
        var autocomplete = new google.maps.places.Autocomplete(postal, options);
<input id="postalCode" type="text" size="50" autocomplete="off">