一旦点击该按钮后禁用按钮 [英] Disable the button after clicking the button once
问题描述
在我的应用程序需要禁用按钮一旦点击,使用户不应该点击超过一次。应用程序是ASP.NET MVC我已经在正常asp.net应用程序做到了这一点。
我想下面code线,但它不工作
In my application i need to disable the button once it is clicked so that user should not click more than once. APplication is MVC ASP.NET i have done this in normal asp.net application. I tried below lines of code but its not working
在此先感谢
编辑
我怎样才能实现这个使用JavaScript?
edited How can i implement this using javascript ?
推荐答案
我发现,与IE8(我不知道IE浏览器的其它版本),如果你禁用点击按钮,你不能提交表单事件。所以,我想出了一个替代的解决方案。隐藏点击按钮,把一个新的禁用按钮,在它的地方。这里的code:
I've found that with IE8 (I'm not sure about other versions of IE) that you cannot submit a form if you disable the button on the click event. So I came up with an alternate solution. Hide the clicked button and put a new disabled button in it's place. Here's the code:
$().ready(function() {
$("someButtonSelector").click(function () {
$(this).hide();
$(this).after('<input type="button" disabled="disabled" value="' + $(this).val() + '" />');
return true;
});
});
这篇关于一旦点击该按钮后禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!