This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var changedObjects = []; | |
// inputs | |
for (input of document.getElementsByTagName("input")){ | |
var changed = false; | |
switch (input.type) { | |
case 'hidden': | |
case 'text': | |
if (input.value != input.defaultValue){ | |
changed = true; | |
} | |
break; | |
case 'radio': | |
case 'checkbox': | |
if (input.checked != input.defaultChecked){ | |
changed = true; | |
} | |
} | |
if (changed){ | |
changedObjects.push(input); | |
} | |
} // inputs | |
// textareas | |
for (textarea of document.getElementsByTagName("textarea")){ | |
if (textarea.value != textarea.defaultValue){ | |
changedObjects.push(textarea); | |
} | |
} // textarea | |
// Select Lists | |
for (select of document.getElementsByTagName("select")){ | |
if (!select.options[select.selectedIndex].defaultSelected){ | |
changedObjects.push(select); | |
} | |
}// select | |
console.log('Changed', changedObjects) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not able to reproduce your bug - my demo application (which uses this code) features a number field : https://apex.oracle.com/pls/apex/haydenhhudson/r/warn-on-unsaved-changes-plugin