0

All major browsers seems to support change event on the HTMLFormElement. (https://stackoverflow.com/a/51846602/1627401)
It is triggered whenever any child Form Control Element's value is changed. This seems to be better approach than adding Event Listeners on all control elements. However, I'm not able to find any reference to this in any of the documentations https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event https://www.w3schools.com/jsref/event_onchange.asp

My question is, is it valid/safe to use this in production code?

MWaheed
  • 306
  • 3
  • 9

1 Answers1

1

Yes, you can add it to a higher element.

The event is emitted from the individual form controls elements, but you are simply listening at a higher level.

See: https://www.quirksmode.org/dom/events/change.html and the section labeled Event bubbling. change events will bubble up and so you can monitor them as you describe.

Chase
  • 3,028
  • 14
  • 15