input 中 type='text' 的提交问题
2010-12-31 13:25
591 查看
有时候我们希望回车键敲在文本框(input element)里来提交表单(form),但有时候又不希望如此。比如搜索行为,希望输入完关键词之后直接按回车键立即提交表单,而有些复杂表单,可能要避免回车键误操作在未完成表单填写的时候就触发了表单提交。
要控制这些行为,不需要借助 JavaScript,浏览器已经帮我们做了这些处理,下面举几个例子来说明:
默认情况下,一个文本框的时候,提交,不管按钮 type 是 submit 还是 button:
view source
print?
一个文本框的时候怎么才能做到不提交,方法是加一个隐藏掉的文本框:
view source
print?
只要有type为submit的按钮存在,一个文本框还是多个文本框都提交:
view source
print?
view source
print?
多个文本框的时候,不提交,用type为button的按钮就行啦:
view source
print?
用button元素时,FF和IE下有不同的表现:
view source
print?
radio和checkbox在FX下也会触发提交表单,在IE下不会:
view source
print?
type为image的按钮,等同于type为submit的效果
view source
print?
转载:http://liuna718-163-com.javaeye.com/blog/808850
wordoor.com
要控制这些行为,不需要借助 JavaScript,浏览器已经帮我们做了这些处理,下面举几个例子来说明:
默认情况下,一个文本框的时候,提交,不管按钮 type 是 submit 还是 button:
view source
print?
1 | < form action = "http://www.nowamagic.net" > |
2 | < input type = "text" > |
3 | < input type = "button" value = "提交" > |
4 | </ form > |
view source
print?
1 | < form action = "http://www.nowamagic.net" > |
2 | < input type = "text" > |
3 | < input type = "text" style = "display:none" > |
4 | < input type = "button" value = "提交" > |
5 | </ form > |
view source
print?
1 | < form action = "http://www.nowamagic.net" > |
2 | < input type = "text" > |
3 | < input type = "submit" value = "提交" > |
4 | </ form > |
print?
1 | < form action = "http://www.nowamagic.net" > |
2 | < input type = "text" > |
3 | < input type = "text" > |
4 | < input type = "submit" value = "提交" > |
5 | </ form > |
view source
print?
1 | < form action = "http://www.nowamagic.net" > |
2 | < input type = "text" > |
3 | < input type = "text" > |
4 | < input type = "button" value = "提交" > |
5 | </ form > |
view source
print?
1 | < form action = "http://www.nowamagic.net" > |
2 | < input type = "text" > |
3 | < input type = "text" > |
4 | < button >提交</ button > |
5 | </ form > |
view source
print?
1 | < form action = "http://www.nowamagic.net" > |
2 | < input type = "text" > |
3 | < input type = "radio" name = "a" > |
4 | < input type = "checkbox" name = "b" > |
5 | < input type = "checkbox" name = "c" > |
6 | < input type = "button" value = "提交" > |
7 | </ form > |
view source
print?
1 | < form action = "http://www.nowamagic.net" > |
2 | < input type = "text" > |
3 | < input type = "text" > |
4 | < input type = "image" src = "http://www.nowamagic.net/images/FeedMe.jpg" > |
5 | </ form > |
wordoor.com
相关文章推荐
- jquery.get的参数中文自动编码与header(\'Content-type: text/html; charset=gbk\');乱码问题
- 使用<input type="text" value=<%=str%>>出现取值不全的问题
- 关于MATLAB函数不可用问题。??? Undefined function or method 'minfo' for input arguments of type 'double'.
- contentType 'text/xml; charset=UTF-8' conflicts问题
- Tag:input type='file' 的文件长度问题
- 表单input中type=text的提交问题
- Jquery 获取指定 table下 所有 type='text' 的 input
- 【DOM操作】实时监听input[type='text']和HTML标签中属性改变事件
- 关于<input type="text">不能显示空格的问题
- 今天遇到一个问题,原来在html的form中如果只有一个type="text"的控件,如果在text中点击回车键,就是自动提交表单!
- 关于<input type="text">不能显示空格的问题
- css去input(type=text'')边框
- <input type="text" 鼠标移动去清空默认value onclick=javascript:this.value=''
- css去input(type=text'')边框
- 关于dsound.h的问题error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
- Flask 应用程序外部可见问题: typeerror run() got an unexpected keyword argument 'host'.
- 表单按回车自动提交 1、当form表单中只有一个<input type="text" name='name' />时按回车键将会自动将表单提交。 <form id='form1' action='a
- EL表达式问题:javax.el.PropertyNotFoundException: Property 'post' not readable on type java.lang.Boolean
- Android EditText的inputType为Password时, 字体不一致的问题
- <input type=“text” name="">width设定无效