Switch / Flag State Change Detection

I need to reliably detect the change in state of the radio buttons / checkboxes on my page in order to see if the form has been changed or not. Now this is a completely separate script, I can not change anything that controls the form.

Now I see only two ways to do this:

  • onchange an event handler that helps with text fields, text fields and selections, but does not start for checkboxes / radio buttons
  • onclick an event handler that is not reliable because users often use hotkeys to change the values ​​of these elements.

What am I missing here? Is there a way to reliably detect that the checkbox is checked or not checked?

UPDATE: As you guys pointed out that the change event is actually triggered on checkboxes / radio buttons, even though w3schools says it is only for text inputs

However, my problem turned out to be that the values ​​of the flags / radio objects are set using setAttribute in the scripts, in which case the event does not fire.

Is there anything I can do in this case?

+5
source share
2 answers

See: http://www.quirksmode.org/dom/events/change.html .

It says that all major browsers support the change event, but the IE implementation is wrong.

IE , , . , - .

, IE . blur(), ! ( - $('input[type=radio]').focus(function(){$(this).blur();}); jQuery javascript)

+1

, , . : Firefox , , Firefox. , .

, , checkbox/radiobutton Firefox, :

onchange , .

, ...

, .

0

All Articles