Deaktiviert Submit-Button für 5 Sekunden und bis User interagiert
This commit is contained in:
parent
a890676745
commit
e2affa38fc
1 changed files with 10 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue