diff --git a/public/js/index.js b/public/js/index.js index 12035e0..d6647d1 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -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 @@ -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.') } @@ -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) })) }