codes/script.js hinzugefügt
This commit is contained in:
parent
45fa169886
commit
1c19507cd6
1 changed files with 32 additions and 0 deletions
32
codes/script.js
Normal file
32
codes/script.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<script>
|
||||
/**
|
||||
* Donau2Space – Newsletter Checkbox Guard
|
||||
*
|
||||
* Verhindert Formular-Submit ohne gesetzte Checkbox
|
||||
* und deaktiviert den Submit-Button bis zur Zustimmung.
|
||||
*/
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
document.querySelectorAll('.d2s-newsletter-wide').forEach(form => {
|
||||
const cb = form.querySelector('.d2s-checkbox input[type="checkbox"]');
|
||||
const btn = form.querySelector('.d2s-btn');
|
||||
|
||||
if (!cb || !btn) return;
|
||||
|
||||
// Initialzustand
|
||||
btn.disabled = !cb.checked;
|
||||
|
||||
// Button erst aktiv, wenn Checkbox aktiv
|
||||
cb.addEventListener('change', () => {
|
||||
btn.disabled = !cb.checked;
|
||||
});
|
||||
|
||||
// Sicherheitsnetz: ohne Haken kein Submit
|
||||
form.addEventListener('submit', (e) => {
|
||||
if (!cb.checked) {
|
||||
e.preventDefault();
|
||||
cb.focus();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Loading…
Reference in a new issue