Formular Zusatzmodule Freiberufliche erstellt
This commit is contained in:
parent
8f8168dbeb
commit
7a9bcaaef8
4 changed files with 107 additions and 23 deletions
|
|
@ -1,5 +1,7 @@
|
|||
window.onload = function () {
|
||||
|
||||
const FORMDEBUG = false;
|
||||
|
||||
// initieiere Zeitmessung zur Botprevention
|
||||
var startTime = Date.now();
|
||||
|
||||
|
|
@ -10,43 +12,49 @@ window.onload = function () {
|
|||
userInteracted = true;
|
||||
}
|
||||
|
||||
// Eventlistener für Interaktionen - setzt userInteracted auf true bei Interaktion
|
||||
document.addEventListener("mousedown", setUserInteracted);
|
||||
document.addEventListener("touchstart", setUserInteracted);
|
||||
document.addEventListener("keydown", setUserInteracted);
|
||||
|
||||
document.getElementById('formular').addEventListener('submit', function (e) {
|
||||
e.preventDefault(); // Verhindert die Standard-Formularsendung
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
var honeyPot = document.getElementById("verify_email").value;
|
||||
const form = e.target;
|
||||
const data = new FormData(form);
|
||||
const notification = document.getElementById('notification');
|
||||
const btn = document.getElementById('bestellformular-btn');
|
||||
const zsrTooltip = document.getElementById('zsr-tooltip');
|
||||
|
||||
var endTime = Date.now();
|
||||
var timeSpent = (endTime - startTime) / 1000; // Zeit in Sekunden
|
||||
document.getElementById("age").value = timeSpent;
|
||||
|
||||
// Setze die Werte für die Botvalidierung zum Auswerten in PHP
|
||||
document.getElementById("age").value = timeSpent;
|
||||
document.getElementById("hobbies").value = userInteracted ? "true" : "false";
|
||||
|
||||
const form = e.target;
|
||||
// Validierung der ZSR-Nummer
|
||||
const zsrNummer = form.elements['zsr_nummer'].value;
|
||||
const isNumberOrBeantragt = /^\d+$|^beantragt$/i.test(zsrNummer);
|
||||
// TODO REGEX für ZSR-Nummer
|
||||
if (!isNumberOrBeantragt) {
|
||||
// Display error message for invalid zsr_nummer
|
||||
const tooltip = document.getElementById('tooltip');
|
||||
tooltip.className = 'input-tooltip';
|
||||
zsrTooltip.className = 'input-tooltip';
|
||||
// Scroll to the tooltip element
|
||||
tooltip.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" });
|
||||
zsrTooltip.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" });
|
||||
return;
|
||||
}
|
||||
|
||||
const data = new FormData(form);
|
||||
const notification = document.getElementById('notification');
|
||||
const btn = document.getElementById('bestellformular-btn');
|
||||
console.log("userInteracted: " + userInteracted);
|
||||
console.log("timeSpent: " + timeSpent);
|
||||
console.log("hobbies: " + document.getElementById("hobbies").value);
|
||||
console.log("age: " + document.getElementById("age").value);
|
||||
console.log("verify_email: " + honeyPot);
|
||||
|
||||
if (FORMDEBUG) {
|
||||
console.log("userInteracted: " + userInteracted);
|
||||
console.log("timeSpent: " + timeSpent);
|
||||
console.log("hobbies: " + document.getElementById("hobbies").value);
|
||||
console.log("age: " + document.getElementById("age").value);
|
||||
console.log("verify_email(honeypot): " + document.getElementById("verify_email").value);
|
||||
}
|
||||
|
||||
// Formulardaten an den Server senden
|
||||
fetch(form.action, {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue