From 0598ec1159818ab704ba56ebd99b957a2bc2e520 Mon Sep 17 00:00:00 2001 From: Ross <9055337+chadsr@users.noreply.github.com> Date: Fri, 28 Jun 2024 12:26:57 +0200 Subject: [PATCH] disable contact form fieldset during submit (#150) --- assets/ts/main.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/assets/ts/main.ts b/assets/ts/main.ts index bf5ac124..68eed234 100644 --- a/assets/ts/main.ts +++ b/assets/ts/main.ts @@ -243,6 +243,7 @@ document.addEventListener('DOMContentLoaded', function () { const contactForm = document.getElementById(CONTACT_FORM_ID); if (contactForm) { + const contactFieldset = contactForm.querySelector('fieldset'); const contactFormBtn = ( document.getElementById(CONTACT_FORM_BUTTON) ); @@ -313,12 +314,20 @@ document.addEventListener('DOMContentLoaded', function () { ); // don't reset the form on error, so the user can try again }); + + if (contactFieldset) { + contactFieldset.disabled = false; + } } ); contactForm.addEventListener('submit', (submitEvent) => { submitEvent.preventDefault(); + if (contactFieldset) { + contactFieldset.disabled = true; + } + if ( contactForm.fullName.value && contactForm.email.value &&