You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It should be easy to integrate with SvelteKit Form Actions so a single set of validation errors can be used for both client-side and server-side validation.
It should just be a case of setting the initial validation state from the ActionData returned from the server, probably a case of "use the standard ValidityState flags when returning the state on the server")
<inputname="email"type="email"value={form?.email??''}>
{#ifform?.missing}<pclass="error">The email field is required</p>{/if}
{#ifform?.incorrect}<pclass="error">Invalid credentials!</p>{/if}
It should return the validation errors for each field using the standard validation flags:
Then the hints setup for client-side validation could be re-used:
{#if$email.valueMissing}Email address is required{/if}
{#if$email.typeMismatch}Not a valid email address{/if}
{#if$email.customError}Invalid credentials{/if}
Obviously, the form couldn't be submitted if it fails to verify with the standard inbuilt browser validations, but it's useful to be able to re-used state and it's possible that one POST happened to not load the JS and another one does, so this should work with either.
The text was updated successfully, but these errors were encountered:
It should be easy to integrate with SvelteKit Form Actions so a single set of validation errors can be used for both client-side and server-side validation.
It should just be a case of setting the initial validation state from the
ActionData
returned from the server, probably a case of "use the standardValidityState
flags when returning the state on the server")So instead of the example in the SK docs:
It should return the validation errors for each field using the standard validation flags:
And on the client we'd probably do something like:
Then the hints setup for client-side validation could be re-used:
Obviously, the form couldn't be submitted if it fails to verify with the standard inbuilt browser validations, but it's useful to be able to re-used state and it's possible that one POST happened to not load the JS and another one does, so this should work with either.
The text was updated successfully, but these errors were encountered: