按Enter回车键实现登录

来源:互联网 发布:淘宝的购物车在哪里 编辑:程序博客网 时间:2024/05/16 19:36
第一种方法:        <html xmlns="http://www.w3.org/1999/xhtml" ><head>  <title>Check Score</title><script language="JavaScript">function keyLogin(){  if (event.keyCode==13)   //回车键的键值为13     document.getElementById("input1").click();  //调用登录按钮的登录事件}</script> </head><body onkeydown="keyLogin();"><input id="input1" value="登录" type="button" onClick="alert('调用成功!')"></body> </body></html>第二种方法: <script>function KeyDown(){    if (event.keyCode == 13)    {        event.returnValue=false;        event.cancel = true;        Form1.btnsubmit.click();    }}</script>使用方法:<form name="Form1" method="">用户名:<INPUT TYPE=text SIZE=20 maxlength = 8 onkeydown=KeyDown()>密码:<INPUT TYPE=password SIZE=20 maxlength = 8 onkeydown=KeyDown()><input type="submit" name="btnsubmit" value="提交" /></form>
0 0