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 buttonsonclick 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?
source
share