formState

This object contains information about the entire form state. It helps you to keep on track with the user's interaction with your form application.

Returns


NameTypeDescription
isValidAccessor<boolean>Set to true if the form doesn't have any errors.
isDirtyAccessor<boolean>Set to true after the user modifies any of the inputs.
errorsFieldErrorsStore proxy object with field errors.
dirtyFieldsAccessor<DirtyFields>Accessor to get user-modified fields. Make sure to provide all inputs' defaultValues via createForm, so the library can compare against the defaultValues.
touchedFieldsAccessor<TouchedFields>Accessor to get all the inputs the user has interacted with.
isSubmittedAccessor<boolean>Set to true after the form is submitted. Will remain true until the reset method is invoked.
submitCountAccessor<number>Number of times the form was submitted.
import { createForm } from "solid-hook-form" export const ExampleForm = () => { const { formState, register, handleSubmit } = createForm({ defaultValues: { test: "" } }) const { isValid, isDirty, errors } = formState const onSubmit = (values) => { console.log(values) } return ( <form onSubmit={handleSubmit(onSubmit)}> <input {...register("test", { required: true })} aria-invalid={!!errors.test} /> <button type="submit" disabled={!isValid() || !isDirty()}> Submit </button> </form> ) }