Are you trying to prevent visitors from entering unverified addresses?
The easiest way to do that is probably to separate your autocomplete field from the actual form field you’re submitting. I’d arrange the form as three fields-
- Autocomplete field, where the user types, and the autocomplete happens. This field serves no other purpose and does not even need to be submitted with the form data. Name it
ignore
or something. - Address field, which is marked
readonly
by script. The user cannot type here but they can see the results. This field is also markedrequired
so it must be populated before the form can submit. - You # Bedrooms and any other fields.
When the user is interacting with field #1, and selects an address from the dropdown, the autocomplete’s place_changed
event fires, and you can then-
- Populate the Address field
- Clear the Autocomplete field
Now the form is submittable, and it will only contain content that was in Google’s autocomplete list.