1

jsFiddle example

before i added the line:

$('form').submit(function(){
    $('input[type=submit]', this).attr('disabled', 'disabled');
});

was working(sending the info with the post) , after i added that disable stuff to prevent double clicking, the form won't send the info but the disable is working and FORM not

please tell me, did i added wrong the line 5 ? should i add the disable code in another place ?

STILL NO SOLUTION !

4

2 回答 2

2

您必须返回 true,才能执行提交:

$('form').submit(function(){
    $('input[type=submit]', this).attr('disabled', 'disabled');
    return true;
});

检查jQuery submit,它说:

这发生在实际提交之前,因此我们可以通过在事件对象上调用 .preventDefault() 或从我们的处理程序返回 false 来取消提交操作。

于 2012-07-05T14:56:14.317 回答
1

你的问题是:

 onclick="return checkDuplicateMessage()"

不要将 jQuery 和内联事件处理程序结合起来。

相反,去:

$('form').submit(function() {
    //cancel the submit if there's a duplicate
    if(!checkDuplicateMessage())
        return false;

    $(this).find('input[type=submit]').prop('disabled', true);
});
于 2012-07-05T15:00:32.070 回答