diff --git a/views/register.ejs b/views/register.ejs index 985b1b6..44b0625 100644 --- a/views/register.ejs +++ b/views/register.ejs @@ -84,6 +84,12 @@ + + @@ -202,7 +208,7 @@ + id="agreeConsent"> Einverständnis gelesen @@ -276,6 +282,44 @@ function nextStep(step){ if(step === 3){ buildSummary(); + checkAgeAndConsent(); + } +} + +function checkAgeAndConsent(){ + + const data = + JSON.parse(localStorage.getItem('registerData')); + + if(!data || !data.geburtsdatum) return; + + const birth = new Date(data.geburtsdatum); + const today = new Date(); + + let age = today.getFullYear() - birth.getFullYear(); + + const m = today.getMonth() - birth.getMonth(); + if (m < 0 || (m === 0 && today.getDate() < birth.getDate())) { + age--; + } + + const consentBox = + document.getElementById('agreeConsent'); + + if(!consentBox) return; + + // Unter 18 → aktiv & Pflicht + if(age < 18){ + + consentBox.disabled = false; + consentBox.required = true; + + } else { + + // Ab 18 → deaktiviert + consentBox.checked = false; + consentBox.disabled = true; + consentBox.required = false; } } @@ -386,6 +430,7 @@ function buildSummary(){ let html = ` Name: ${data.vorname} ${data.nachname} + Geburtsdatum: ${data.geburtsdatum} Email: ${data.email} Mobil: ${data.mobil} Adresse: