$("#btnLogin").unbind("click").bind("click", function () { var user = $("#txt_userName").val(); var pass = $("#txt_password").val(); $.get("/Batch/OtherAshx.ashx?Type=checklogin&user=" + user + "&pass=" + pass, function (data) { if (data != "") { alert(data); return false; } else { location.reload(); } }); }); $("body").keydown(function () { if (event.keyCode == "13") {//keyCode=13 is the Enter key $('#btnLogin').click(); } });