zoukankan      html  css  js  c++  java
  • 回车提交、连续点击、layer提示

    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             }
    View Code

    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);
    View Code
    收藏
    关注
    评论
  • 相关阅读:
    work_7_Boolean和boolean,基本类型和包装类型
    work_06_服务器上传图片错误
    work_05_64未随机id生成器
    work_04_谷歌验证码工具Kaptcha
    vue.js_13_vue的搭建
    每日一java(割草机)
    work_03_常见jq问题处理
    work_02_css样式
    java 27
    java 27
  • 原文地址:https://www.cnblogs.com/yidengbone/p/6520157.html
Copyright © 2011-2022 走看看