Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation is not triggered with oninput and value props in Svelte 5 #493

Open
1 task done
rayrw opened this issue Oct 28, 2024 · 1 comment
Open
1 task done

Validation is not triggered with oninput and value props in Svelte 5 #493

rayrw opened this issue Oct 28, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@rayrw
Copy link

rayrw commented Oct 28, 2024

  • Before posting an issue, read the FAQ and search the previous issues.

Description

While it does work when using bind:value in an input tag, validation is not triggered when manually mutating the value via an oninput handler (oninput={e => $form.field = e.currentTarget.value }).

If applicable, a MRE

I've made a minimal reproduction repo. When inputting values in text fields with oninput + value props, the validation is not triggered, but it works when using the text fields with bind:value.

https://sveltelab.dev/github.com/rayrw/svelte5-superforms-proxy-field (right click to open in a new tab)

@rayrw rayrw added the bug Something isn't working label Oct 28, 2024
@ciscoheat
Copy link
Owner

Since the validation is triggered on blur the first time, you need an extra event handler for validating it manually. Something like:

onblur={() => validate('email')}

(validate is available on the superForm object)

@ciscoheat ciscoheat added documentation Improvements or additions to documentation and removed bug Something isn't working labels Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants