当有多个输入文本时,表单无法提交

发布于 2024-10-14 19:12:38 字数 498 浏览 11 评论 0原文

这是一个很容易描述的问题。这已在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

以为你会在 2024-10-21 19:12:38

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.

和我恋爱吧 2024-10-21 19:12:38

此问题有两种可能的解决方案。

  1. 最简单的解决方案是再添加 1 个对用户不可见的输入字段。

  2. 您可以绑定该输入字段的 keydown 事件,并在该函数中只需检查 keyCode == 13 然后 PreventDefault()。

There are two possible solution for this issue.

  1. The simplest solution is to add 1 more input field which will not visible to user.

  2. you can bind the keydown event of that input field, and in that function just check keyCode == 13 then preventDefault().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文