Question

v0 form loses input when validation error shows

Solved · 11 views · asked by yuki_builds · edited

Submit with an empty field: error shows, all other fields are cleared.

What I’ve tried

Asked v0 to 'keep the values'. It added localStorage saving, which is worse.

Comment

1 answer

Marked as helpful by the asker
dev_ana · edited

The form is re-rendering with key or being replaced by a new element on error, so the browser drops the uncontrolled inputs. Return the submitted values from the server action and use defaultValue={state.values.email}, or make the fields controlled. Delete the localStorage code.

Comment