StealThis .dev

Form — Smart address input (autocomplete)

A typeahead address field built on the ARIA combobox pattern that filters a fictional address list as you type, highlights matched substrings, and is fully keyboard-driven with arrow, Enter, Home, End and Escape. Selecting a suggestion auto-fills structured street, city, postcode and country fields, while an Enter manually toggle reveals the full set with live validation, inline errors, an error summary, and a confirmation state.

Open in Lab
html css vanilla-js
Targets: JS HTML

Code

Smart address input (autocomplete)

A shipping form that leads with a single search field. As you type two or more characters, a suggestion dropdown filters a fictional address list and highlights the matched text. The field follows the ARIA combobox pattern — role="combobox" with aria-expanded, aria-controls, aria-autocomplete, and a live aria-activedescendant — so arrow keys move the highlight, Enter selects, Home/End jump to the ends, and Escape closes the list.

Picking a suggestion auto-fills the structured fields (street, city, postcode, country), opens them for review, and confirms with a toast. An “Enter manually” toggle expands the same field set for addresses that aren’t in the list. Every field has a label, placeholder, helper text, a required marker, and real validation: blur and submit checks set aria-invalid, render inline error messages wired via aria-describedby, and mark valid fields with a success state.

On submit, any failures populate a role="alert" error summary whose links focus the offending field, and a polite aria-live status announces the count. A clean form swaps to a confirmation card showing the finalized address, with an Edit button to return — no fake submit, fully keyboard-usable, and responsive down to 360px.