forms: make value property update a function and update textareas too
This commit is contained in:
parent
ab8e756034
commit
a92b657e4a
@ -1,13 +1,20 @@
|
||||
// For labels to update their state (css selectors based on the value attribute)
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
document.querySelectorAll('input').forEach(el => {
|
||||
if (el.type !== 'checkbox') {
|
||||
el.setAttribute('value', el.value);
|
||||
el.addEventListener('change', () => {
|
||||
el.setAttribute('value', el.value);
|
||||
});
|
||||
}
|
||||
});
|
||||
window.updateInputs = () => {
|
||||
document.querySelectorAll('input, textarea').forEach(el => {
|
||||
if (!el.inputSetup) {
|
||||
el.inputSetup = true;
|
||||
if (el.type !== 'checkbox') {
|
||||
el.setAttribute('value', el.value);
|
||||
el.addEventListener('change', () => {
|
||||
el.setAttribute('value', el.value);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
updateInputs();
|
||||
});
|
||||
|
||||
window.applyFormMessages = function (formElement, messages) {
|
||||
|
Loading…
Reference in New Issue
Block a user