Friday 25 September 2015

Jquery: Prevent doubleclicks on button

A simple way in Jquery to prevent a button to be clicked more than once but still allow it to proceed to server-side handling is to add the following Jquery function:

  var clicked = false;
  // Disable saveÅterfört button when clicked once  
     $("#ctl00_Main_btnSaveAterfort").click(function () {
       if (clicked === false) {
         clicked = true;
         $('#ctl00_Main_btnSaveAterfort').trigger('click');
         $(this).attr('disabled', true);
       }
     });