1

I am trying to briefly disable a 'Save' button on a page during requests to prevent users from clicking it twice. Following advice that I found here, I put

elem.setAttribute("disabled","disabled")

at the very beginning of the onclick method, but it doesn't work, I can still click multiple times very fast and cause multiple requests to be sent before the buttons get disabled. Does anyone have any advice?

Art F
  • 3,992
  • 10
  • 49
  • 81

3 Answers3

1

Try using the elements properties instead of its attributes

elem.disabled = true;
Musa
  • 96,336
  • 17
  • 118
  • 137
1

The onclick method can do this, too. In addition to disabling the button.

if (inclick) return;
inclick = true;

... handle the entire click work ...

inclick = false;

be sure to default inclick = false; at the start of the world.

This will make sure any fast clicks get ignored. (It's a sort of 'debouncing' effect.)

Lee Meador
  • 12,829
  • 2
  • 36
  • 42
0

like this

elem.attr("disabled", "disabled");

$("#idButton").attr("disabled", "disabled");

could you help this.

Disabling a submit button after one click

http://jsfiddle.net/V7B3T/12/

Community
  • 1
  • 1
Elfego
  • 11
  • 2