正确禁用提交按钮 [英] properly disabling the submit button
本文介绍了正确禁用提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我用来禁用按钮的代码
$(#btnSubmit)。attr('disabled ','disabled')
$(#btnSubmit)。disabled = true;
这是我的提交按钮
< input id =btnSubmitclass =grayButtonBlueTexttype =submitvalue =Submit/>
该按钮虽然看起来是禁用的,但您仍然可以点击它。这是使用FF 3.0进行测试的, IE6
我在这里做错了什么?
解决方案
$ $ ('#btnSubmit')。unbind('click')。click(function(){return false;});
当您重新启用按钮时,您必须再次添加点击处理程序。
this is the code that I use to disable the button
$("#btnSubmit").attr('disabled', 'disabled')
$("#btnSubmit").disabled = true;
and this is my submit button
<input id="btnSubmit" class="grayButtonBlueText" type="submit" value="Submit" />
the button although looks disabled, you can still click on it.. This is tested with FF 3.0 and IE6
Am I doing something wrong here?
解决方案
Depending on how the form submission is handled you might also need to remove any click handlers and/or add one that aborts the submission.
$('#btnSubmit').unbind('click').click( function() { return false; } );
You'd have to add the click handler's again when (if) you re-enable the button.
这篇关于正确禁用提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文