first commit

This commit is contained in:
2024-11-10 23:50:03 +01:00
commit b6b399febd
9 changed files with 486 additions and 0 deletions

26
js/form_helper.js Normal file
View File

@@ -0,0 +1,26 @@
const inputs = document.querySelectorAll("input")
inputs.forEach(input => {
input.addEventListener(
"invalid",
() => {
input.classList.add("error")
input.nextElementSibling.style.display = "inline"
},
false
)
input.addEventListener(
"input",
event => checkValidityOnInput(event),
false
)
})
function checkValidityOnInput(e){
e.target.checkValidity()
if(e.target.validity.valid) {
e.target.classList.remove("error")
e.target.nextElementSibling.style.display = "none"
}
}