回车键生效:
如果表单里有一个type=”submit”的按钮,回车键生效。
如果表单里只有一个type=”text”的input,不管按钮是什么type,回车键生效。如果按钮不是用input,而是用button,并且没有加type,IE下默认为type=button,FX默认为type=submit。
回车键无效:
1.添加一个<input type='text' style='display:none'/>不显示输入框
<form id='form1' action='a1.jsp' method='post'>
<input type='text' name='name' />
<input style='display:none' />
</form>
2.添加一个onkeydown事件
<form id='form1' action='a1.jsp' method='post'>
<input type='text' name='name' οnkeydοwn='if(event.keyCode==13) return false;'/>
</form>