T
TanStack2mo ago
conscious-sapphire

Why does the validation in the onChangeAsync field trigger again when submitting?

I added onChangeAsync validation to the field, hoping it would only be triggered on change, but when I submit, the validation is triggered again. Why? Is there a way to disable this feature?
3 Replies
dependent-tan
dependent-tan2mo ago
submission ensures that all validators pass, that includes onChangeAsync
conscious-sapphire
conscious-sapphireOP2mo ago
But I think if it's validated during onChangeAsync, the submitted value should be correct, right? Besides, there's bound to be further validation on the backend. For example, if I'm checking a username or account number, I only need to know if the username hasn't been used yet. If the onchangeasync function passes, I don't need to hit the API again when submitting, because the value I'm expecting has already passed validation.
dependent-tan
dependent-tan2mo ago
It misses multiple edge cases: * The user submits without changing a field. * The user simply blurs the field so the form is touched and then submits. * There is a field onChangeAsync validator that wasn't executed because a different field was changed and then the user submitted.

Did you find this page helpful?