We have a lot of forms on a website we're developing. Some of these forms have functionality that will populate specific fields using JavaScript based on something else the user does. (For example postcode lookup).
For every form, we want to do something when each form field value is modified.
On change events aren't fired by values changed by JavaScript.
MutationObserver doesn't appear to be able to listen to value changes (it only listens for attribute changes, not property changes). Unless I am missing something?
We don't want to (and in some cases can't) change the JavaScript that populates fields to trigger the on change event.
So, we have a form which may have fields values populated by some JavaScript or another somewhere along the way, and we need to know when the field's values have changed.
Currently the only working solution we've come up with is to use 'polling' to periodically check all fields (using setInterval) to see if their value has changed. We're wondering if anyone can come up with a better solution?
(We are using jQuery 1.11.2).
Update: We have found an answer to this question which I have posted below. However, we do not know what the ramifications of redefining an object's default property might be, so we aren't 100% comfortable with that solution yet and continue to search for more ideas.