diff --git a/app/inquiry.php b/app/inquiry.php index 510d66d..77a629d 100644 --- a/app/inquiry.php +++ b/app/inquiry.php @@ -147,7 +147,9 @@ function inquiry_submit(array $input, string $ip): array if ($values['name'] === '') { $errors[] = $labels['name']; } - if (preg_match('/[0-9+][0-9 ()\/+.-]{4,}/', $values['phone']) !== 1) { + // Nur die Ziffern zählen: 0172 6384350, +49 172 638 43 50 und + // 0172/6384350 sind alle gültig, "abc" oder "123" nicht. + if (strlen((string) preg_replace('/[^0-9]/', '', $values['phone'])) < 6) { $errors[] = $labels['phone']; } if (filter_var($values['email'], FILTER_VALIDATE_EMAIL) === false) { diff --git a/web/assets/js/main.js b/web/assets/js/main.js index b4bd7d6..c4e2b6a 100644 --- a/web/assets/js/main.js +++ b/web/assets/js/main.js @@ -154,19 +154,25 @@ return; } - if (phone && !/[0-9+][0-9 ()\/+.-]{4,}/.test(phone.value.trim())) { + // Eigene Hinweise zuerst leeren: sonst blockiert eine alte Meldung + // (z. B. "Bitte eine erreichbare Telefonnummer angeben") auch nach der + // Korrektur noch jeden weiteren Versuch. + if (phone) phone.setCustomValidity(''); + if (dateTo) dateTo.setCustomValidity(''); + + // Nur die Ziffern zählen – Schreibweisen wie 0172 6384350, + // +49 172 638 43 50 oder 0172/6384350 sind alle gültig. + if (phone && phone.value.replace(/[^0-9]/g, '').length < 6) { phone.setCustomValidity('Bitte eine erreichbare Telefonnummer angeben.'); form.reportValidity(); return; } - if (phone) phone.setCustomValidity(''); if (dateFrom && dateTo && dateFrom.value && dateTo.value && dateTo.value < dateFrom.value) { dateTo.setCustomValidity('Das Ende der Miete muss nach dem Beginn liegen.'); form.reportValidity(); return; } - if (dateTo) dateTo.setCustomValidity(''); if (submitButton) submitButton.disabled = true; showStatus('Ihre Anfrage wird gesendet …', false); diff --git a/web/index.html b/web/index.html index 7c13add..4826616 100644 --- a/web/index.html +++ b/web/index.html @@ -21,7 +21,7 @@ - + +