控制用户多次点击提交-----Ajax

    在用户点击确定后,为防止用户多次点击,应在用户点击时加一个点击事件。点击即触发

1、前台aspx页面的html,需要在head中引用js文件PageAjax.js

<head>  
<script src="../js/PageAjax.js" type="text/javascript"></script>
</head>
<body>
<input type="text" id="inputYear"/>
<
a class="btn_a" id="confirm" onclick='controlConfirm(this)' value="确定">确定</a>
</body>

2、前台Js文件PageAjax.js

function controlConfirm(obj) {if ($(obj).html() == "确定") {//点击后隐藏,防止连续点击
        $(obj).attr("style", "visibility:hidden");
        //判断是否填写
        if (isNullEmpty($("#inputYear").val())) {
            //如果不为空,不操作;如果空则提示并显示确定按钮。
        }
        else {
            alert("请输入数据!!!");
            $(obj).attr("style", "visibility:visible");
            return;
        }
       /* if (submitHtml.indexOf("background-color: red") > 0) {
            alert("不准保存!!!!");
            $(obj).attr("style", "visibility:visible");
            return;*/
      }

 

posted @ 2015-04-08 12:44  紫之灵玲  阅读(332)  评论(0编辑  收藏  举报