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

OnChange (handleChange func) #162

Open
arensade opened this issue Apr 20, 2022 · 2 comments
Open

OnChange (handleChange func) #162

arensade opened this issue Apr 20, 2022 · 2 comments

Comments

@arensade
Copy link

Hi,
I'm curious what is exactly handleChange in example page

When we remove on:change={handleChange} still getting changes on submit function.

@dlebech
Copy link
Contributor

dlebech commented May 12, 2022

If you have bind:value={$form.someValue} on your form field, then the form will still get updated when the field changes.

Therefore, it looks like handleChange is not necessary.

However, handleChange both changes the value of the form field and it runs validation on the field instantly. It requires a name or id field on the form field to work.

When you use bind:value as well as handleChange, I guess the value is technically being updated twice -- once by Svelte and once by the forms lib. As such, you could argue that bind:value={$form.someValue} should be changed to value={$form.someValue in the examples.

@dlebech
Copy link
Contributor

dlebech commented May 12, 2022

See also this issue which describes the same thing: #159 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants