锘?(function () { $("#UserId").keydown(input_onkeydown); $("#Password").keydown(input_onkeydown); $("#Code").keydown(input_onkeydown); $("#btn_login").click(btn_login_click); }); function input_onkeydown(e) { if (e.which == 13) { $('#btn_login').click(); } } function btn_login_click() { var sUserId = $('#UserId').val(); var sPassword = $('#Password').val(); var sCode = $('#Code').val(); if (sUserId == "") { showMsg("甯愭埛涓嶈兘涓虹┖锛?) $('#UserId').focus(); } else if (sPassword == "") { showMsg("瀵嗙爜涓嶈兘涓虹┖锛?) $('#Password').focus(); } else if (sCode == "") { showMsg("璇疯緭鍏ユ牎楠岀爜锛?); $('#Code').focus(); } else { showMsg('鐧诲綍涓?..'); $.ajax({ url: _json_base.SourcePath + '/all_login_ajax.ashx', type: 'POST', data: { action: 'DoLogin', said: _json_base.said, UserId: sUserId, Password: sPassword, Code: sCode }, dataType: 'text', cache: false, success: function (result, s, r) { if (result == 'ok') { showMsg('鐧诲綍鎴愬姛锛?); location.href = _json_base.rurl; } else { showMsg(result); $('#CodeImg').attr('src', $('#CodeImg').attr('src') + '?'); $('#Code').val(''); } }, error: function (r, s, err) { showMsg('鐧诲綍鍑虹幇閿欒锛?); }, complete: function (r, s) { // } }); } } function showMsg(s) { $('#div_msg').html(s); }