Using jquery I\'ve added a change handler to a form. This works when any input is changed BUT only if the user manually changes an input and not when some other code changes
This is easily achieved in JavaScript without jQuery. initChangeDetection() can be called multiple times:
function initChangeDetection(form) {
Array.from(form).forEach(el => el.dataset.origValue = el.value);
}
function formHasChanges(form) {
return Array.from(form).some(el => 'origValue' in el.dataset && el.dataset.origValue !== el.value);
}
Test on JS Bin
function initChangeDetection(form) {
for (var i=0; i