Filling City From Google Api Only

183 views Asked by At

I have an Asp Textbox. Now i want to integrate it to get cities of a specific country and provide autocomplete feature in it. That i accomplished using this.

var options = {
                types: ['(cities)'],
                componentRestrictions: { country: "in" }
              };
new google.maps.places.Autocomplete(document.getElementById('txtPlaces'),options);

Now what i want to do is to provide a validation such that user has to select a city from Auto Complete and cannot enter any other unknown city.

The validation should also provide some indication to user such that he/she knows that the value entered is correct and can move on to fill next values

Please help me out on this. Thanx in Advance.

1

There are 1 answers

0
Dr.Molle On BEST ANSWER

Observe the place_changed-event of the Autocomplete, when the place has a geometry-property it's a valid place based on the suggestions