I want a simple onclick alert on a disabled checkbox: <input type="checkbox" name="myBox" id="myBox" value="my value" disabled onclick="alert('This checkbox is disabled because..');" > It seem though that a disabled checkbod does not respond to events. The onclick works perfectly on the TD that the input is in. Creating an image representation of a checkbox is not an option since I'll need this function for select as well. Any ideas?
Instead of disabling it, you could inhibit it: <input type='checkbox' onclick="if(this.checked && !somethingDone){this.checked=false;alert('You haven\'t finished something yet')}"> Code (markup):
Ok, so events are indeed disabled for form objects that are disabled? The thing is that I thought that only changing values was disabled.
hi! Read here: http://stackoverflow.com/questions/7833854/jquery-detect-click-on-disabled-submit-button
Disabled checkboxes do not fire events. In order to solve the issue you can place an empty div on top of the checkbox and detect the click on the (invisible, empty) div. See a sample solution here: http://stackoverflow.com/questions/...-function-when-a-disabled-checkbox-is-clicked
Honestly, if whatever text explaining why it's disabled is that important, why the blazes isn't it in the label? Skip the scripttard BS altogether.