Disable submit button ONLY after submit

前端 未结 13 671
囚心锁ツ
囚心锁ツ 2020-12-02 22:49

I have the following HTML and jquery:






Test disabling submit button fo

13条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 23:39

    I faced the same problem. Customers could submit a form and then multiple e-mail addresses will receive a mail message. If the response of the page takes too long, sometimes the button was pushed twice or even more times..

    I tried disable the button in the onsubmit handler, but the form wasn't submitted at all. Above solutions work probably fine, but for me it was a little bit too tricky, so I decided to try something else.

    To the left side of the submit button, I placed a second button, which is not displayed and is disabled at start up:

       
    
    

    In the onsubmit handler attached to the form, the 'real' submit is hidden and the 'fake' submit is shown with a message that the messages are being sent.

    function checkinput // submit handler
    {
        ..
        ...
        $("#btnverzenden").hide(); <= real submit button will be hidden
        $("#btnverzenden2").show(); <= fake submit button gets visible
        ...
        ..
    }
    

    This worked for us. I hope it will help you.

提交回复
热议问题