Validation Shake

An invalid field that shakes, a valid one that earns a check

Enter a valid email

Add animated validation to a form field. On submit with an invalid value: the field shakes horizontally with transform keyframes 0, -6px, 6px, -4px, 4px, 0 over 320ms, its border turns the error red, and an inline error message (13px, red) appears directly under the field. Reserve the error line's height in advance so nothing jumps. Typing again clears the error state. On submit with a valid value: the border turns success green and a small SVG check mark inside the field draws itself using the stroke-dasharray / stroke-dashoffset technique over 400ms ease-out. Validate on submit (and optionally on blur), never on every keystroke. Announce the error with role="alert" for screen readers. If prefers-reduced-motion is enabled, skip the shake and the check drawing, but keep the colors and message. Build the component, not this demo of it. - Ambient motion that IS the component may loop: a drifting background, a marquee, a spinner while something is genuinely loading. - Do not add any timer, interval, loop or script that performs a person's action by itself. No auto-hover, no auto-click, no cycling through states, no pretend submitting, no replaying the interaction on a schedule. - Every state that answers a person waits for a real event from that person. - Placeholder copy and sample content are welcome. Simulated behaviour is not.

Rate it
0
0

We'd like to measure how the site gets used, with Google Analytics. It sets cookies. Everything the site needs to work runs either way. How we handle data