仅在提交后禁用提交按钮 [英] Disable submit button ONLY after submit

查看:44
本文介绍了仅在提交后禁用提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下 HTML 和 jquery:

I have the following HTML and jquery:

<html dir="ltr" lang="en">
<head>
</head>
<body>

<h2>Test disabling submit button for 1 minute...</h2>

<br/>

<p style="text-align:center"> 
<form id="yourFormId" name="yourFormId" method="post" action="#">
 <input type="submit" class="submitBtn" value="I Accept"/>
</form>
</p>




<!--script to disable the submit button -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">  
</script>
<script type="text/javascript">

$(document).ready(function () {
    $(".submitBtn").click(function () {
        $(".submitBtn").attr("disabled", true);
        return true;
    });
});

</script>
<!--script ends here-->

</body>
</html>

就其本身而言,按下提交按钮时会被禁用.然而,一旦按下它似乎不会执行提交.如果我删除了 jquery 以禁用按钮,则该按钮会正常执行提交.

As its stands the submit button gets disabled when pressed. However once pressed it does not seem perform the submit. If I removed the jquery to disable the button, the button then performs the submit normally.

如何仅在执行提交后禁用该按钮?上面当前的jquery好像和submit操作有冲突.

How can I disable the button only after it has performed the submit? the current jquery above seems to conflict with the submit operation.

任何解决此问题的建议都会非常有帮助.

Any suggestions to resolve this issue would be extremely helpful.

推荐答案

在提交事件中添加禁用部分.

Add the disable part in the submit event.

$(document).ready(function () {
    $("#yourFormId").submit(function () {
        $(".submitBtn").attr("disabled", true);
        return true;
    });
});

这篇关于仅在提交后禁用提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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