add js code to enforce the max attribute for number inputs

pull/139/head
Aevann 2023-03-12 16:45:52 +02:00
parent 81550b4386
commit e5b21825aa
1 changed files with 8 additions and 0 deletions

View File

@ -189,3 +189,11 @@ document.addEventListener("click", function(e){
document.querySelector(element.dataset.toggleelement).classList.toggle(element.dataset.toggleattr);
}
});
const inputs = document.querySelectorAll('input[type="number"]')
for (const input of inputs) {
input.onkeyup = () => {
console.log(1)
if (parseInt(input.value) > parseInt(input.max)) input.value = input.max;
};
}