实现回车登录提交表单的代码,如下:
<script language="javascript" type="text/javascript">
//page 有两个button,两个textbox,回车触发第二个button
var x = document.getElementById('<%=Textbox1.ClientID %>'); //获取控件对象
x.onkeydown = txtsubmit;
var y = document.getElementById('<%=TextBox2.ClientID %>');
y.onkeydown = txtsubmit;
function txtsubmit() {
var e = event.srcElement;
if (event.keyCode == 13) {
document.getElementById('<%=Button2.ClientID %>').click(); //提交按钮Button2
return false;
}
}
</script>