本文介绍了禁用提交按钮,直到对表单元素进行任何更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是我正在尝试做的事情.提交表单后,我要禁用提交"按钮,直到更改任何表单元素.我已经在stackoverflow上使用了一个不同的问题,几乎可以正常工作了:

Heres what im trying to do. After the form is submitted, i want to disable the submit button until any form element is changed. I already got it almost working using a different question on stackoverflow:

$('#myform').find (':submit').attr ('disabled', 'disabled');

// Re-enable submit
var form = $('#myform');
$(':input', form.get(0)).live ('change', function (e) {
    form.find (':submit').removeAttr ('disabled');
});

一个问题是,如果禁用了按钮,并且用户单击了该按钮,则表示更改并现已启用.因此,只需双击该按钮即可重新提交!有什么建议吗?

One problem is that the if the button is disabled, and the user clicks the button, that counds as a change and its now enabled. So a simple double click of the button re-submits! Any suggestions?

推荐答案

[type!="submit"]

http://api.jquery.com/attribute-not-equal-selector/

$(':input[type!="submit"]', form.get(0)).live ('change', function (e) {
    form.find (':submit').removeAttr ('disabled');
});

这篇关于禁用提交按钮,直到对表单元素进行任何更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 22:15