disable the submit button after it clicked once

Here is my client website http://www.tswanda.co.zw/campaigns/tswanda-childrens-home/ when you click on contribute now a popup window appear with donate button, if you click on donate button 2, 3 or 4 times it submitted the value again for checkout.

I want to disable button once a money is submitted can you please help me out i tried hard use code from Disabling links to stop double-clicks in JQuery but nothing work for me.

Read More

any help will be really appreciated.

<script type="text/javascript">
       function do_nothing() { 
            return false;
           }

           // prevent a second click for 10 seconds. :)
                jQuery('.edd-add-to-cart').live('click', function(e) { 
                    jQuery(e.target).click(do_nothing); 
                      setTimeout(function(){
                     jQuery(e.target).unbind('click', do_nothing);
                    }, 50000); 
                  });


    </script>

Related posts

Leave a Reply

3 comments

  1. You can disable the button when clicked, and re-enable it after 5 seconds:

             jQuery('.edd-add-to-cart').live('click', function(e) { 
                 var element = $(this);
                 jQuery(e.target).click(do_nothing); 
                 element.attr("disabled", "disabled");
                 setTimeout(function(){
                     element.removeAttr("disabled");
                 }, 50000); 
              });
    
  2. Inside your click handler,You are binding another click event to the target. And you’re removing that particular click handler.

    Instead the try disabling the button by setting up disabled attribute and remove it.

    function do_something() {
        alert("doing something");   
    }
    
    // prevent a second click for 10 seconds. :)
    
    jQuery('.edd-add-to-cart').live('click', function (e) {
          var self = this;
          $(this).attr("disabled", "disabled");
          do_something();
          setTimeout(function () {
              $(self).removeAttr('disabled');
          }, 10000);
      });
    

    DEMO