asp.net回车换焦的问题
<html>
<head><title>测试keydown</title>
<SCRIPT LANGUAGE="JavaScript">
function enterkey()
{
if(event.keyCode==13 && event.srcElement.type !="BUTTON" && event.srcElement.type!="SUBMIT")
event.keyCode=9;
}
</SCRIPT>
</head>
<body>
<form id="form1" method="post">
<input type="text" id="txt1" onkeydown="enterkey();">
<input type="text" id="txt2" onkeydown="enterkey();">
<input type="text" id="txt3" onkeydown="enterkey();">
<input type="button" id="btn" Text="提交" onclick="alert('不再跳下去了');">
</form>
</body>
</html>
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
Tab(TextBox1);
Tab(TextBox2);
}
public void Tab(System.Web .UI.WebControls .WebControl webcontrol)
{
webcontrol.Attributes .Add ("onkeydown", "if(event.keyCode==13) event.keyCode=9");
}
<head><title>测试keydown</title>
<SCRIPT LANGUAGE="JavaScript">
function enterkey()
{
if(event.keyCode==13 && event.srcElement.type !="BUTTON" && event.srcElement.type!="SUBMIT")
event.keyCode=9;
}
</SCRIPT>
</head>
<body>
<form id="form1" method="post">
<input type="text" id="txt1" onkeydown="enterkey();">
<input type="text" id="txt2" onkeydown="enterkey();">
<input type="text" id="txt3" onkeydown="enterkey();">
<input type="button" id="btn" Text="提交" onclick="alert('不再跳下去了');">
</form>
</body>
</html>
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
Tab(TextBox1);
Tab(TextBox2);
}
public void Tab(System.Web .UI.WebControls .WebControl webcontrol)
{
webcontrol.Attributes .Add ("onkeydown", "if(event.keyCode==13) event.keyCode=9");
}