东莞春雷化工有限公司:怎样实现在文本框中按回车键,光标跳到下一个文本框,而不是提交?

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/07 10:52:59
怎样实现在文本框中按回车键,光标跳到下一个文本框,而不是提交?

<input type=text name=username onkeydown="form1.password.focus()">

上面的都是错的,把我的代码拷过去改一下就行了.
<body>
<script>

function a()
{

if(event.keyCode==13){
event.cancelBubble=true;
event.returnValue=false;
document.form1.elements(1).focus();
}
}
document.onkeypress=a;
</script>

<form name="form1">
<input type="text" >
<input type="text">
<input type="submit">
</form>

</body>

楼上的不行,因为会按下所有键都会转到下一个文本框,应该判断按下什么键盘了:
<input type=text name=text1 onkeydown="call Text1_onKeypress()">

<SCRIPT language=vbscript>
Sub Text1_onKeypress()
If window.event.keycode=13 then '回车键的keycode等于13
text2.focus
End If
End Sub
</SCRIPT>

按tab键呀