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

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

问题描述

我有以下的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>

作为其代表时pressed提交按钮被禁用。然而,一旦pressed它似乎不执行提交。如果我删除了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似乎与提交操作相冲突。

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天全站免登陆