neue Bestellseite
This commit is contained in:
parent
ddf001fe6a
commit
de71b1f24e
@ -86,8 +86,8 @@
|
||||
|
||||
<input type="date"
|
||||
name="geburtsdatum"
|
||||
id="geburtsdatum"
|
||||
class="form-control"
|
||||
placeholder="Geburtsdatum"
|
||||
required>
|
||||
|
||||
<input name="mobil" class="form-control" placeholder="Mobilnummer" required>
|
||||
@ -139,7 +139,12 @@
|
||||
|
||||
|
||||
<div class="form-check mt-2">
|
||||
<input class="form-check-input" type="checkbox" name="agreeSepa" required>
|
||||
<input class="form-check-input"
|
||||
type="checkbox"
|
||||
name="agreeSepa"
|
||||
value="on"
|
||||
required>
|
||||
|
||||
<label class="form-check-label">
|
||||
SEPA-Mandat erteilen
|
||||
</label>
|
||||
@ -203,25 +208,30 @@
|
||||
|
||||
<h5>Rechtliches</h5>
|
||||
|
||||
<div class="form-check mb-2">
|
||||
|
||||
<!-- Eltern-Zustimmung -->
|
||||
<div class="form-check mb-2 d-none" id="consentBox">
|
||||
|
||||
<input class="form-check-input"
|
||||
type="checkbox"
|
||||
name="agreeConsent"
|
||||
id="agreeConsent">
|
||||
id="agreeConsent"
|
||||
value="on">
|
||||
|
||||
<label class="form-check-label">
|
||||
Einverständnis gelesen
|
||||
Einverständnis der Erziehungsberechtigten
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- AGB -->
|
||||
<div class="form-check mb-3">
|
||||
|
||||
<input class="form-check-input"
|
||||
type="checkbox"
|
||||
name="agreeAgb"
|
||||
value="on"
|
||||
required>
|
||||
|
||||
<label class="form-check-label">
|
||||
@ -265,13 +275,12 @@ let currentStep = 1;
|
||||
|
||||
function nextStep(step){
|
||||
|
||||
// 👉 Nur validieren, wenn wir vorwärts gehen
|
||||
// Nur vorwärts validieren
|
||||
if(step > currentStep){
|
||||
if(!validateStep(currentStep)) return;
|
||||
}
|
||||
|
||||
saveForm();
|
||||
|
||||
|
||||
currentStep = step;
|
||||
|
||||
@ -290,40 +299,50 @@ function nextStep(step){
|
||||
}
|
||||
}
|
||||
|
||||
function checkAgeAndConsent(){
|
||||
|
||||
const data =
|
||||
JSON.parse(localStorage.getItem('registerData'));
|
||||
/* ============================
|
||||
ALTER PRÜFEN
|
||||
============================ */
|
||||
|
||||
if(!data || !data.geburtsdatum) return;
|
||||
function isUnder18(){
|
||||
|
||||
const birth = new Date(data.geburtsdatum);
|
||||
const bday =
|
||||
document.getElementById('geburtsdatum').value;
|
||||
|
||||
if(!bday) return false;
|
||||
|
||||
const birth = new Date(bday);
|
||||
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())) {
|
||||
if(
|
||||
today.getMonth() < birth.getMonth() ||
|
||||
(today.getMonth() === birth.getMonth() &&
|
||||
today.getDate() < birth.getDate())
|
||||
){
|
||||
age--;
|
||||
}
|
||||
|
||||
const consentBox =
|
||||
document.getElementById('agreeConsent');
|
||||
return age < 18;
|
||||
}
|
||||
|
||||
if(!consentBox) return;
|
||||
|
||||
// Unter 18 → aktiv & Pflicht
|
||||
if(age < 18){
|
||||
function checkAgeAndConsent(){
|
||||
|
||||
consentBox.disabled = false;
|
||||
consentBox.required = true;
|
||||
const box = document.getElementById('consentBox');
|
||||
const checkbox = document.getElementById('agreeConsent');
|
||||
|
||||
} else {
|
||||
if(isUnder18()){
|
||||
|
||||
// Ab 18 → deaktiviert
|
||||
consentBox.checked = false;
|
||||
consentBox.disabled = true;
|
||||
consentBox.required = false;
|
||||
box.classList.remove('d-none');
|
||||
checkbox.required = true;
|
||||
|
||||
}else{
|
||||
|
||||
box.classList.add('d-none');
|
||||
checkbox.required = false;
|
||||
checkbox.checked = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,19 +399,27 @@ function updateNav(){
|
||||
|
||||
|
||||
/* ============================
|
||||
AUTO SAVE
|
||||
AUTO SAVE (MIT CHECKBOX FIX)
|
||||
============================ */
|
||||
|
||||
const form = document.getElementById('registerForm');
|
||||
|
||||
form.addEventListener('input', saveForm);
|
||||
|
||||
|
||||
function saveForm(){
|
||||
|
||||
const data = {};
|
||||
|
||||
new FormData(form).forEach((v,k)=>{
|
||||
data[k]=v;
|
||||
Array.from(form.elements).forEach(el=>{
|
||||
|
||||
if(!el.name) return;
|
||||
|
||||
if(el.type === 'checkbox'){
|
||||
data[el.name] = el.checked ? 'on' : '';
|
||||
}else{
|
||||
data[el.name] = el.value;
|
||||
}
|
||||
});
|
||||
|
||||
localStorage.setItem('registerData',
|
||||
@ -409,10 +436,13 @@ function loadForm(){
|
||||
|
||||
Object.keys(data).forEach(key=>{
|
||||
|
||||
const field =
|
||||
form.elements[key];
|
||||
const field = form.elements[key];
|
||||
|
||||
if(field){
|
||||
if(!field) return;
|
||||
|
||||
if(field.type === 'checkbox'){
|
||||
field.checked = data[key] === 'on';
|
||||
}else{
|
||||
field.value = data[key];
|
||||
}
|
||||
});
|
||||
@ -440,7 +470,6 @@ function buildSummary(){
|
||||
<b>Adresse:</b>
|
||||
${data.strasse} ${data.hausnummer},
|
||||
${data.plz} ${data.ort}<br>
|
||||
|
||||
<b>IBAN:</b> ${data.iban}<br>
|
||||
`;
|
||||
|
||||
@ -458,5 +487,3 @@ form.addEventListener('submit',()=>{
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<%- include('partials/footer') %>
|
||||
Loading…
Reference in New Issue
Block a user