StealThis .dev

Form — Submit success / confirmation states

A contact form that walks the whole submit lifecycle in front of you: idle, then a sending state with a button spinner and disabled fields, then either a confirmed receipt or a recoverable error. Success paints an animated SVG checkmark, a personalized confirmation, and a copyable reference number with a Submit-another reset. The failure path raises a role=alert banner with a retry button, and an aria-live region announces every outcome. Real inline validation, no fake submit.

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

Code

Submit success / confirmation states

A four-field contact form (name, work email, topic, message) built to show the full submit lifecycle rather than just a fire-and-forget POST. Each field validates on blur and then live as you type, with inline error text wired through aria-describedby, an aria-invalid flag, and matching red/green border states plus a trailing status icon. The message field carries a live character counter that warns as it nears its limit.

Pressing Send message runs a real validation pass first — if anything is wrong it focuses the first invalid field and announces the problem. When the form is valid the button enters its sending state: a spinner appears, the label switches to “Sending…”, and the control is disabled with aria-busy. The simulated round-trip fails on the first attempt so the recovery path is visible: a role="alert" banner explains the timeout and offers a Retry button. The retry succeeds and the form swaps to a confirmation panel with an animated drawn-on SVG checkmark, a greeting using the sender’s first name, and a unique REQ-XXXX-XXXX reference number.

Every transition is announced through a polite aria-live status region and echoed in a toast, focus moves to the success heading for keyboard and screen-reader users, and Submit another fully resets the form back to its idle state. The layout stacks cleanly down to 360px and respects prefers-reduced-motion.