Fix search form validation

This commit is contained in:
2026-01-15 15:17:20 +01:00
parent d1e741ebfd
commit 8c216c7e56
5 changed files with 23 additions and 21 deletions

View File

@@ -1,5 +1,7 @@
// use Bootstrap 5's Tab component to manage tab navigation and synchronize with URL hash
document.addEventListener("DOMContentLoaded", function () {
'use strict';
const selectElement = document.getElementById('tabSelector');
// code to handle tab selection and URL hash synchronization
const hash = window.location.hash.substring(1) // remove the '#' prefix
@@ -8,7 +10,7 @@ document.addEventListener("DOMContentLoaded", function () {
const trigger = document.querySelector(`[data-bs-target="${target}"]`);
if (trigger) {
bootstrap.Tab.getOrCreateInstance(trigger).show();
selectElement.value = target // keep the dropdown in sync
selectElement.value = target; // keep the dropdown in sync
}
}
@@ -35,7 +37,7 @@ document.addEventListener("DOMContentLoaded", function () {
document.querySelectorAll('[data-bs-toggle="tab"]').forEach(btn => {
btn.addEventListener('shown.bs.tab', event => {
const target = event.target.getAttribute('data-bs-target');
selectElement.value = target
selectElement.value = target;
});
});
});

View File

@@ -0,0 +1,15 @@
document.addEventListener("DOMContentLoaded", function () {
'use strict'
const forms = document.querySelectorAll('.needs-validation')
Array.from(forms).forEach(form => {
form.addEventListener('submit', event => {
if (!form.checkValidity()) {
event.preventDefault()
event.stopPropagation()
}
form.classList.add('was-validated')
}, false)
})
});