Files
musenalm/views/routes/suche/components/_fieldscript.gohtml
Simon Martens b8f36274fc Nach Typ suchen
2025-03-10 14:38:10 +01:00

54 lines
1.3 KiB
Plaintext

<script type="module">
let fieldset = document.querySelector("fieldset.selectgroup");
if (fieldset) {
let checkboxes = Array.from(fieldset.querySelectorAll('input[type="checkbox"]'));
fieldset.addEventListener("change", (event) => {
let target = event.target;
if (target.type === "checkbox") {
let name = target.name;
let checked = target.checked;
if (!checked) {
let allchecked = checkboxes.filter((checkbox) => checkbox.checked);
if (allchecked.length === 0) {
target.checked = true;
}
}
}
});
}
const form = document.getElementById("simplesearchform");
let submitBtn = null;
if (form) {
submitBtn = form.querySelector("#submitbutton");
}
function checkValidity(f, btn) {
if (f.checkValidity()) {
btn.disabled = false;
} else {
btn.disabled = true;
}
}
if (form && submitBtn) {
checkValidity(form, submitBtn);
form.addEventListener("input", (event) => {
checkValidity(form, submitBtn);
});
}
const lookupform = document.getElementById("lookupform");
let lookupsubmitBtn = null;
if (lookupform) {
lookupsubmitBtn = lookupform.querySelector("#submitbutton");
}
if (lookupform && lookupsubmitBtn) {
checkValidity(lookupform, lookupsubmitBtn);
lookupform.addEventListener("input", (event) => {
checkValidity(lookupform, lookupsubmitBtn);
});
}
</script>