KeyCode Enter登陆时候的使用
HTML
用户名:<input type="text" id="UserAccount" onKeyPress="JumpByEnter(UserPwd)" />
密码:<input name="UserPwd" type="password" onKeyPress="IsEnterKeyPress()">
JavaScript:
JumpByEnter(UserPwd) 函数功能:输入完用户名按回车,焦点转向密码输入框
IsEnterKeyPress()功能:输入完密码并按回车,则登录
function JumpByEnter(NextElement){
var lKeyCode = (navigator.appname=="Netscape")?event.which:window.event.keyCode; //event.keyCode按的建的代码,13表示回车
if ( lKeyCode == 13 ){
NextElement.focus();
}
function IsEnterKeyPress(){
var lKeyCode = (navigator.appname=="Netscape")?event.which:event.keyCode;
if ( lKeyCode == 13 ){
Login();
}
else
return false;
}