1、回车提交
1 /*******************回车键提交***********************************/ 2 document.onkeydown = function (e) { 3 var ev = document.all ? window.event : e; 4 if (ev.keyCode == 13) { 5 if ($(".ds_dialog").length > 0) { 6 return; 7 } 8 return CheckInput('txtUserName', 'txtCheckCode', 'lblError', 'hidErrCount'); 9 } 10 }
2.连续点击、alert
1 /*******************登录提交***********************************/ 2 var isEnabledClick = 0; //防止连续点击 3 function CheckInput(txtUserName, txtCheckCode, lblError, txtErrCount){ 4 var paramUserName = document.getElementById(txtUserName).value; 5 var paramCheckCode = document.getElementById(txtCheckCode).value; 6 var lang = document.getElementById("lang").value; 7 if (paramUserName.length <= 0) { 8 var errorMsg = lang == "en" ? "please input the User Name!" : "请输入用户名!"; 9 layer.alert(errorMsg, { 10 title: lang == "en" ? "Message reminding" : '消息提示', 11 btn: [lang == "en" ? "yes" : "确定"] 12 }); 13 $("#txtUserName").focus(); 14 return; 15 } 16 17 var pwd = $("#txtPassWord").val(); 18 if (pwd.length <= 0) { 19 var errorMsg = lang == "en" ? "please input the User password!" : "请输入密码!"; 20 layer.alert(errorMsg, { 21 title: lang == "en" ? "Message reminding" : '消息提示', 22 btn: [lang == "en" ? "yes" : "确定"] 23 }); 24 $("#txtPassWord").focus(); 25 return; 26 } 27 /////////////// 28 if (isEnabledClick == 0) { 29 isEnabledClick = 1; 30 $("#btnLogin").attr('disabled', "true"); 31 } 32 else { 33 var errorMsg = lang == "en" ? "Logging in, please later!" : "已经提交,请等待......"; 34 layer.alert(errorMsg, { 35 title: lang == "en" ? "Message reminding" : '消息提示', 36 btn: [lang == "en" ? "yes" : "确定"] 37 }); 38 return; 39 } 40 setTimeout(function () { 41 isEnabledClick = 0; 42 }, 3000);