单个文本框并提交行为 [英] Single text box and submit behaviour
问题描述
< html> 我有一个单一的文本框,
< form action =http://www.google.com>
< input type =text/>
< / form>
< / html>
当文本框被选中时,我按回车键表单将被提交并显示谷歌页面。
但是如果我有两个文本框如下:
< html>
< form action =http://www.google.com>
< input type =text/>
< input type =text/>
< / form>
< / html>
现在,如果我按提交按钮,什么都不会发生。
任何人都可以在这里解释:
i)为什么表单在第一种情况下被提交?
ii)为什么表单没有在第二种情况下提交?
当表单中只有一个单行文本输入字段时,
用户代理应接受该字段中的Enter作为提交
表单的请求。
禁用此行为的最简单方法是添加一个隐藏的输入字段。
I have a single text box with no submit button on form as below :
<html>
<form action="http://www.google.com">
<input type="text"/>
</form>
</html>
when text box is selected and i press enter key form will get submitted and google page will be displayed. however if i have two text box as bellow :
<html>
<form action="http://www.google.com">
<input type="text"/>
<input type="text"/>
</form>
</html>
now if i press submit button nothing will happen.
Can anyone explain here :
i) why form is get submitted in first case?
ii) why form is not submitting in second case?
When there is only one single-line text input field in a form, the user agent should accept Enter in that field as a request to submit the form.
The easiest way to disable this behavior is to add a hidden input field.
这篇关于单个文本框并提交行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!