按Enter键提交一个输入的HTML表单,但不是两个 [英] Pressing enter submits HTML form with one input, but not two
问题描述
jsFiddle (一个输入): http://jsfiddle.net/gpPTa/
jsFiddle(两个输入):< a href =http://jsfiddle.net/fDbJt/> http://jsfiddle.net/fDbJt/
不幸的是,它只是一个默认的输入提交表单,只有一个输入。
你可以给每个人一个javascript命令提交表单,或者放置宽度为0和/或可见性:无的提交按钮。
例如:
< form>
< input style ='width:0; visibility:hidden'type ='submit'>
<输入>
<输入>
< / form>
Can anyone explain this behavior? Pressing the Enter key in an HTML form's text box submits the form when the form contains a single text box, but not when the form contains two or more text boxes.
jsFiddle (one input): http://jsfiddle.net/gpPTa/
jsFiddle (two inputs): http://jsfiddle.net/fDbJt/
Unfortunately it's a default for the form to submit on enter with only one input.
You can either give each of them an javascript command that submits the form, or place a submit button with width: 0 and/or visibility: none. For example:
<form>
<input style='width:0; visibility:hidden' type='submit'>
<input>
<input>
</form>
这篇关于按Enter键提交一个输入的HTML表单,但不是两个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!