对于表单,没有提交按钮,有 1 个文本输入,请按 Enter 提交。
对于表单,没有提交按钮,有超过1个文本输入,不要回车提交。
两者都不应该在 Enter 上提交吗?
<!-- This one do submit on Enter -->
<form action="/">
<input type="text" name="firstname" value="Mickey">
</form>
<!-- This one do not submit on Enter -->
<form action="/">
<input type="text" name="firstname" value="Mickey">
<input type="text" name="lastname" value="Jerry">
</form>
最佳答案
If the form has no submit button, then the implicit submission mechanism must do nothing if the form has more than one field that blocks implicit submission, and must submit the form element from the form element itself otherwise.
https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#implicit-submission
您可以在此处查看没有提交按钮的表单如何工作: https://www.tjvantoll.com/2013/01/01/enter-should-submit-forms-stop-messing-with-that/#no-submit-buttons
关于html - Enter 上没有提交按钮的表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45629219/