From e2affa38fc1fc5f2495f41e1e224002c2ddf28e3 Mon Sep 17 00:00:00 2001 From: Andreas Hnida Date: Tue, 27 Feb 2024 10:37:56 +0000 Subject: [PATCH] =?UTF-8?q?Deaktiviert=20Submit-Button=20f=C3=BCr=205=20Se?= =?UTF-8?q?kunden=20und=20bis=20User=20interagiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/js/bestellformular.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/assets/js/bestellformular.js b/assets/js/bestellformular.js index 9ab5568..6e3d88c 100644 --- a/assets/js/bestellformular.js +++ b/assets/js/bestellformular.js @@ -1,6 +1,7 @@ window.onload = function () { const FORMDEBUG = false; + const btn = document.getElementById('bestellformular-btn'); // initieiere Zeitmessung zur Botprevention var startTime = Date.now(); @@ -9,9 +10,17 @@ window.onload = function () { var userInteracted = false; function setUserInteracted() { + var timeSpent = (Date.now() - startTime) / 1000; // Zeit in Sekunden + if (timeSpent > 5) { + btn.disabled = false; + } userInteracted = true; } - + setTimeout(function () { + if (userInteracted) { + btn.disabled = false; + } + }, 5000); // Eventlistener für Interaktionen - setzt userInteracted auf true bei Interaktion document.addEventListener("mousedown", setUserInteracted); document.addEventListener("touchstart", setUserInteracted); @@ -23,7 +32,6 @@ window.onload = function () { const form = e.target; const notification = document.getElementById('notification'); - const btn = document.getElementById('bestellformular-btn'); const zsrTooltip = document.getElementById('zsr-tooltip'); // Spinner und button disabled anzeigen