*
The moose likes HTML, CSS and JavaScript and the fly likes how to disable onclick event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to disable onclick event" Watch "how to disable onclick event" New topic
Author

how to disable onclick event

reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
I have an input tag with type=button, and an onclick event being set on it. When I disable this button by adding disabled=disabled to it, I still can click and trigger the onclick JS function of this button.

Why is the onclick still working when the button is disabled? How could I also disabled the onclick event? Thanks


SCJA, SCJP5.0, SCBCD, SCWCD
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Which browser are you using? Show a working code snippet. I cannot reproduce this in FF and IE.



The disabled one doesn't show up the alert when clicked. Neither IE nor FF.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16



[My Blog]
All roads lead to JavaRanch
reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
thanks guys, yeh, it's actually my fault. when I look closer in the code, I saw that button is inside a td tag, I disabled the td, the button looks like disabled, as greyed out, but onclick is still working. when I disabled with the button id, it worked.
 
Don't get me started about those stupid light bulbs.
 
subject: how to disable onclick event
 
Similar Threads
Prevent multiple submits (e.g. double clicks) in a4j:CommandLink
How to stop the onclick function running when onsubmit validation fail
Image Buttons and Disabling them
Editable form
getting forceId in h:commandLink