n8n-workflow-listmonk-antispam/codes/script.js

32 lines
No EOL
840 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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>