Winverständniserklärung nur bei unter 18
This commit is contained in:
parent
a7b78cfed4
commit
ab5d615194
@ -84,6 +84,12 @@
|
||||
|
||||
<input name="nachname" class="form-control" placeholder="Nachname" required>
|
||||
|
||||
<input type="date"
|
||||
name="geburtsdatum"
|
||||
class="form-control"
|
||||
placeholder="Geburtsdatum"
|
||||
required>
|
||||
|
||||
<input name="mobil" class="form-control" placeholder="Mobilnummer" required>
|
||||
|
||||
<input type="email" name="email" class="form-control" placeholder="E-Mail" required>
|
||||
@ -202,7 +208,7 @@
|
||||
<input class="form-check-input"
|
||||
type="checkbox"
|
||||
name="agreeConsent"
|
||||
required>
|
||||
id="agreeConsent">
|
||||
|
||||
<label class="form-check-label">
|
||||
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 = `
|
||||
<b>Name:</b> ${data.vorname} ${data.nachname}<br>
|
||||
<b>Geburtsdatum:</b> ${data.geburtsdatum}<br>
|
||||
<b>Email:</b> ${data.email}<br>
|
||||
<b>Mobil:</b> ${data.mobil}<br>
|
||||
<b>Adresse:</b>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user