3 ms·
I was under the impression that a disabled submit button would also prevent the form by submitting on enter/return, is this not the case?
by agos 3y ago
I was under the impression that a disabled submit button would also prevent the form by submitting on enter/return, is this not the case?
- anon23432343 3y agoNo you can submit by pressing enter. for example if you have an login form and your focus is on the PW and you press enter then it still will be sent.
- dbrgn 3y agoThat depends on whether it's actually a classic HTML <form>, or whether it's just a collection of input fields submitted through JavaScript. And of course, if you disable the button, you could prevent duplicate form submission as well through the onsubmit event.
- recursive 3y agoThis is missing a detail. This only works if there is not a disabled `type=submit` element inside the form.
- chrismorgan 3y agoYou are correct, and the original article is incorrect in this point (a pity, since the rest seems sound). Spec reference: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#implicit-submission https://html.spec.whatwg.org/multipage/form-control-infrastr... (It’s not written in the most obvious way as regards this detail, but it’s clearly there: if there is a default button, click on it, if you can—implied is: if you can’t, just do nothing; and if there isn’t a default button, try to just submit the form.)