Form Validation with NextJS 13
Answered
Black-throated Sparrow posted this in #help-forum
Black-throated SparrowOP
Hello all, the question is as the title says. Currently I am validating my forms through the use of state - I have a
handleSubmit() function which does a series of checks on the input values stored in state, only submitting the form data if all those checks are passed. However, this has the obvious downside of having to use a client component instead of a server component. Is there any way of getting around this?Answered by fuma
Currently, there’s no a workaround to implement it without client component. You can validate it in the server action, but you’ll have a bad UX due to the limitations of server action: You can’t display an error with server action.
3 Replies
Currently, there’s no a workaround to implement it without client component. You can validate it in the server action, but you’ll have a bad UX due to the limitations of server action: You can’t display an error with server action.
Answer
@fuma Currently, there’s no a workaround to implement it without client component. You can validate it in the server action, but you’ll have a bad UX due to the limitations of server action: You can’t display an error with server action.
Black-throated SparrowOP
That's perfectly fine, I'm updating UI on the frontend dynamically so I suppose that it's basically impossible; was just making sure anyway
Thanks!