How to prevent submit enhanced form when hit enter in an input field? #8657
NormandoHall
started this conversation in
General
Replies: 1 comment 1 reply
-
I like the answer you found that includes the aria attribute and works without JavaScript. However, you can also implement the other answer with svelte if you prefer, such as <!-- Disallow enter key anywhere -->
<form on:keydown={(event) => event.key != 'Enter'}>
</form> |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I like enhanced form SK provides, but it is impossible to prevent submit (with cancel() in this case) when the user hit ENTER in any field. I want the user only submit the form when click the submit button.
Based on this answer in Stack Overflow, I workaround adding a disabled button at the beginning of the form:
<button type="submit" disabled style="display: none" />
But looks very weird. Is there a better way to get the same behaviour?
Regards
Beta Was this translation helpful? Give feedback.
All reactions