为什么表单没有提交,如果有多个未命名的输入? [英] Why are forms not submitted if there is more than one unnamed input?

查看:193
本文介绍了为什么表单没有提交,如果有多个未命名的输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<form method="POST" action="">
    <input type="text" />
    <input type="text" />
</form>

JSFiddle

输入中按回车。然后删除其中一个输入 s并再次按下。当表单中有两个输入时,表单不会被提交(然后我们需要一个按钮)。为什么会这样?

Press enter on the input. Then delete one of the inputs and press it again. When we have two inputs inside of the form, the form is not submitted (we need a button then). Why is that?

推荐答案

单个输入的HTML表单的默认行为是在enter上提交。只要添加第二个输入,按回车将不再提交表单。姓名的缺乏与此无关。

The default behavior of HTML forms with a single input is to submit on enter. As soon as you add a second input, pressing enter will no longer submit the form. The presense or lack of names has nothing to do with it.

这篇关于为什么表单没有提交,如果有多个未命名的输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆