如何从点击按钮不止一次prevent用户? [英] How to prevent user from clicking button more than once?

查看:166
本文介绍了如何从点击按钮不止一次prevent用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从点击提交按钮不止一次试图prevent用户。我尝试了一些东西是对所以对于类似的问题。

I am trying to prevent user from clicking the submit button more than once. I tried a number of things which are on SO for similar issue.

例如像:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js">
    $('<% =btnUpload.ClientID %>').click(function () { this.disabled = true });
</script>

我也试过..

<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js">
  $("form").submit(function() {
    $(this).submit(function() {
        return false;
    });
    return true;
  });
</script>

和还试图...母版页

<form onsubmit="if(submitted) return false; submitted = true; return true">

但是没有用..
我仍然能够在点击链接超过一次。

But to no use.. I am still able to click on button more than once.

标记

<asp:Button ID="btnUpload" runat="server" class="blue-button" 
CssClass="ButtonText"OnClick="btnUpload_Click"
 OnClientClick="if (!confirm('Are you sure that you want to Save entered details ?'))
 return false;return doCustomValidate(event,true);"
     Text="Save" />

另外请注意,我用的母版页这样

Also note that I am using master page so

推荐答案

禁用属性添加到它。

$('#<% =btnUpload.ClientID %>').click(function () {
    $(this).prop("disabled", true);
});

这篇关于如何从点击按钮不止一次prevent用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆