Skip to content

Commit

Permalink
disable contact form fieldset during submit (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
chadsr authored Jun 28, 2024
1 parent a2c9f78 commit 0598ec1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions assets/ts/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ document.addEventListener('DOMContentLoaded', function () {

const contactForm = <ContactForm>document.getElementById(CONTACT_FORM_ID);
if (contactForm) {
const contactFieldset = contactForm.querySelector('fieldset');
const contactFormBtn = <HTMLButtonElement>(
document.getElementById(CONTACT_FORM_BUTTON)
);
Expand Down Expand Up @@ -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 &&
Expand Down

0 comments on commit 0598ec1

Please sign in to comment.