In my signup form I have a field which requires that the user types in his/her address and city (autocomplete).
Problem is that it's also possible for the user to just type his/her city without the street and submit the form.
Does anyone has a solution for this?
<script>
var input = document.getElementById('adres');
var autocomplete = new google.maps.places.Autocomplete(input,{componentRestrictions: {country:'be'}});
google.maps.event.addListener(autocomplete, 'place_changed', function(){
var place = autocomplete.getPlace();
})
</script>
You can use
autocomplete.setTypes(['address']);
to allow only addresses in the autocomplete.A city is not an address (it's a region), so the autocomplete will not allow it.