Skip to content

Commit

Permalink
tweak: reset turnstile token on succesful form submission
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaleshe committed Feb 7, 2024
1 parent ac5a8cb commit f220799
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions public/js/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* global XMLHttpRequest, alert, turnstile */
const horizontalScrollContainer = document.querySelector('.portfolio__cards__scroll')
const contactForm = document.getElementById('submit-email-form')
const turnstileElement = document.getElementById('ts-captcha')

const horizontalScrollContainer = document.querySelector('.portfolio__cards__scroll')
const btnLeft = document.querySelector('.portfolio__cards__scroll__btn-left')
const btnRight = document.querySelector('.portfolio__cards__scroll__btn-right')
const scrollableWidth = horizontalScrollContainer.scrollWidth
Expand Down Expand Up @@ -50,7 +52,9 @@ const sendEmail = (event) => {
return
}

// Reset form fields and recaptcha token
contactForm.reset()
turnstile.reset(turnstileElement)

alert('Message sent succesfully. Check your email (& spam folder) for confirmation of receipt.')
}
Expand All @@ -63,6 +67,6 @@ const sendEmail = (event) => {
LastName: document.getElementById('LastName').value,
Email: document.getElementById('Email').value,
Message: document.getElementById('Message').value,
Token: turnstile.getResponse(document.getElementById('ts-captcha'))
Token: turnstile.getResponse(turnstileElement)
}))
}

0 comments on commit f220799

Please sign in to comment.