How to properly return custom server-side form error(s)?

Hi,

I’m building a form to allows the user to change the password. One of the fields is the current password, which can’t be validated client-side.

I’m validating the password server-side (Server Action), and if the password is wrong, I’m currently returning a Response 401 (Unauthorized).

However, I’m not sure if this is the correct way to transmit a server-side form error. Surely, there must be a better way to automatically make the client highlight the field that failed validation, right?

Community Page
Last updated: