当有多个输入文本时,表单无法提交
这是一个很容易描述的问题。这已在 Firefox (3.6)、IE (8) 和 Chrome (8) 上进行了测试。
这是文件 doesnotsubmit.html
<form>
<input />
<input />
</form>
当焦点位于其中一个输入并按 Enter 键时,什么也没有发生。
下面是文件 doessubmit.html
<form>
<input />
</form>
当焦点位于输入上并按 Enter 键时,表单将被提交。
对这种不一致的行为有什么见解吗?
我知道该表单缺少提交按钮,因此在语义上不正确。不管怎样,提交过程是通过 jQuery 对话框按钮面板的按钮自动处理的,我不知道如何放置一个额外的 。
This is a quite simple issue to describe. This was tested on Firefox (3.6), IE (8) and Chrome (8).
Here is the file doesnotsubmit.html
<form>
<input />
<input />
</form>
When the focus is on one of the input and you press enter, nothing happens.
Below is the file doessubmit.html
<form>
<input />
</form>
When the focus is on the input and you press enter, the form is submitted.
Any insight on this inconsistent behavior ?
I know the form lacks a submit button, and thus is not semantically correct. Anyway, the submit process was meant to automatically be handled through jQuery dialogs buttonpane's buttons, and I wouldn't know how to place an additional <input type="submit" />.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
user754151 是正确的。这是一个已知的错误,但我想你可以通过拦截 Enter 按键事件来摆脱它。
user754151 is correct. This is a known bug but i guess you can get rid of it just intercepting the enter keypress event.
此问题有两种可能的解决方案。
最简单的解决方案是再添加 1 个对用户不可见的输入字段。
您可以绑定该输入字段的 keydown 事件,并在该函数中只需检查 keyCode == 13 然后 PreventDefault()。
There are two possible solution for this issue.
The simplest solution is to add 1 more input field which will not visible to user.
you can bind the keydown event of that input field, and in that function just check keyCode == 13 then preventDefault().