单个文本框并提交行为 [英] Single text box and submit behaviour

查看:100
本文介绍了单个文本框并提交行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < 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)为什么表单没有在第二种情况下提交?

HTML 2.0规范


当表单中只有一个单行文本输入字段时,
用户代理应接受该字段中的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?

解决方案

HTML 2.0 Specs:

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屋!

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