ExamplesForm

FormKit — validation

Zod rules, client errors, and focus on the first invalid field after submit.

Validation

Submit with empty or invalid values to see errors and focus move to the first field.

How it works

The schema runs through the FormKit resolver before onSubmit. Try an empty username, an invalid username, a non-numeric age, an age outside the allowed range, or an unchecked terms box. The first invalid control receives focus after submission.

This example covers client-side interaction feedback. For authoritative backend rules, throw the API error from onSubmit and map it with the mapServerError prop described in the form guide.

On this page