$(function () { $("#txtUserName").focus();//考生编号输入焦点 $("#txtUserName").keydown(function (event) { if (event.which == "13") {//回车键,移动光标到身份证号 $("#txtPassWord").focus(); } }); $("#txtCheckNo").keydown(function (event) { if (event.which == "13") {//回车键,移动光标到密码框 $("#btnLogin").trigger("click"); } }); $("#btnLogin").click(function () { //“登录”按钮单击事件 //获取用户名称 var strusername = encodeURI($("#txtUserName").val()); //密码 var strpwd = $.md5($("#txtPassWord").val()); //验证码 var strCheckNo = encodeURI($("#txtCheckNo").val()); //开始发送数据 $.ajax ({ //请求登录处理页 url: "Cjgl/Validate_Login_From.aspx", //登录处理页 dataType: "text", //传送请求数据 data: { txtusername: strusername, txtpwd: strpwd,txtCheckNo: strCheckNo }, success: function (strValue) { //登录成功后返回的数据 //根据返回值进行状态显示 if (strValue == "1") { alert('账号或密码不正确!'); } if (strValue == "2") { alert('输入正确的验证码!'); } if (strValue == "3") { alert('账号已锁定,请于5分钟后重试'); } if (strValue == "4") { window.location.href = "Default.aspx"; } if (strValue == "5") { alert('账号或密码错误'); } if (strValue == "0") { alert('登陆失败!'); } } }) }) }) function changeImg() { $("#imgCheckNo").attr("src", "Cjgl/ValidateImage.aspx?r=" + getRandom(999)); } function getRandom(n) { return Math.floor(Math.random() * n + 1) }