Prevent double submission of forms in jQuery

后端 未结 22 1372
旧时难觅i
旧时难觅i 2020-11-22 08:10

I have a form that takes a little while for the server to process. I need to ensure that the user waits and does not attempt to resubmit the form by clicking the button agai

22条回答
  •  遇见更好的自我
    2020-11-22 08:44

    You can stop the second submit by this

    $("form").submit(function() {
            // submit more than once return false
            $(this).submit(function() {
                return false;
            });
            // submit once return true
            return true; // or do what you want to do
        });
    });
    

提交回复
热议问题