Hello peeps,
Could somebody point me where I need to add a javascript to disable the submit button after the form is submitted once? I am trying to prevent multiple submissions which happened today where a form was submitted over 2700 times.
PS: I am also planning on adding CAPTCHA but I have read there is some issues with it.
Thank you in advance!!!
Disable Submit button after...
Hi Sineis,
This can be tricky because if the user has made an error and you hit the submit button the form will report the error but also block the submit. Give this a try.
Paste the code below into a HTML Element with form builder. Export and test.
This can be tricky because if the user has made an error and you hit the submit button the form will report the error but also block the submit. Give this a try.
Paste the code below into a HTML Element with form builder. Export and test.
<script>
document.addEventListener('DOMContentLoaded', function () {
const form = document.querySelector('form'); // Adjust if needed
const button = document.getElementById('fb-submit-button');
form.addEventListener('submit', function (e) {
button.disabled = true;
setTimeout(() => {
const errors = document.querySelectorAll('.error').length;
if (errors > 0) {
button.disabled = false;
}
}, 100);
});
});
</script>
document.addEventListener('DOMContentLoaded', function () {
const form = document.querySelector('form'); // Adjust if needed
const button = document.getElementById('fb-submit-button');
form.addEventListener('submit', function (e) {
button.disabled = true;
setTimeout(() => {
const errors = document.querySelectorAll('.error').length;
if (errors > 0) {
button.disabled = false;
}
}, 100);
});
});
</script>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
It's easy to overlook something you're not looking for.
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.