Question: How to programatically trigger form validation? #3595
-
|
This is a question. If it's not possible, I'll add a formal feature request. Here's the context: As a user, I'd like to submit a form if I press an exact combination of keys. When I do that though, the form submits normally instead of hitting the validation as it does when clicking the submit button. Is there a way to programmatically initialize validation from a function? I'm following the basic approach, specifically: Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
I left out that I've tried adding this to the opening
|
Beta Was this translation helpful? Give feedback.
-
|
I converted this to a discussion because it is not an issue, more of a question. By default, the
I would go with either one of the first two approaches. |
Beta Was this translation helpful? Give feedback.
I converted this to a discussion because it is not an issue, more of a question.
By default, the
Formcomponent handles thesubmitevent only. If you want to handle submissions with other triggers you can either:useFormand get more fine control over the form submission<Form v-slotto render a custom form tag and handle it manuallysubmitevent on the rendered form element withel.dispatchEvent(new Event('submit'))I would go with either one of the first two approaches.