Autocomplete Address Validation

You can validate according to the AddressInput’s value property. As the docs state: " Site visitor selects one of the Google address suggestions: The Address.formatted property and all relevant Address properties that correspond to the selected Google address will contain data. "

I tried a quick experiment… I added an onChange() event to an AddressInput element, and I get the value and display to the console, like this:

export function addressInput1_change(event) {
    let address = $w("#addressInput1").value;
    console.log('change address', address); 
}

Upon inspection of the value, if I enter in an address (free text), only the Address.formatted property has a value and all other fields are undefined. However, when I select one of the suggested addresses, all of the other fields (e.g. country, location) are populated. This can be used to validate the address.

1 Like