mirror of
https://github.com/Start9Labs/start9.com.git
synced 2026-04-01 21:13:11 +00:00
reset contact form and captcha widget on refresh and submission
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -36,7 +36,7 @@ layout: layouts/peripheral.njk
|
|||||||
<h3>Message Us</h3>
|
<h3>Message Us</h3>
|
||||||
<p>Response times are usually between 24-48 hours. For faster support, use one of the options above</p>
|
<p>Response times are usually between 24-48 hours. For faster support, use one of the options above</p>
|
||||||
<div class="contact-form">
|
<div class="contact-form">
|
||||||
<form id="contact-form">
|
<form id="contact-form" autocomplete="off">
|
||||||
<label for="contact-name">Name</label>
|
<label for="contact-name">Name</label>
|
||||||
<input id="contact-name" class="form-control" type="text" placeholder="Your name" required />
|
<input id="contact-name" class="form-control" type="text" placeholder="Your name" required />
|
||||||
<label for="contact-email">Email</label>
|
<label for="contact-email">Email</label>
|
||||||
@@ -53,6 +53,16 @@ layout: layouts/peripheral.njk
|
|||||||
<div id="contact-error" class="form-alert form-alert--error"></div>
|
<div id="contact-error" class="form-alert form-alert--error"></div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
// Clear captcha token on page load (browser may restore it on refresh)
|
||||||
|
document.getElementById('mcaptcha__token').value = '';
|
||||||
|
|
||||||
|
function resetCaptchaWidget() {
|
||||||
|
var container = document.getElementById('mcaptcha__widget-container');
|
||||||
|
var iframe = container.querySelector('iframe');
|
||||||
|
if (iframe) iframe.src = iframe.src;
|
||||||
|
document.getElementById('mcaptcha__token').value = '';
|
||||||
|
}
|
||||||
|
|
||||||
document.getElementById('contact-form').addEventListener('submit', async function(e) {
|
document.getElementById('contact-form').addEventListener('submit', async function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const form = e.target;
|
const form = e.target;
|
||||||
@@ -85,6 +95,7 @@ layout: layouts/peripheral.njk
|
|||||||
|
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
form.reset();
|
form.reset();
|
||||||
|
resetCaptchaWidget();
|
||||||
success.textContent = 'Inquiry received! We will get back to you within 24 hours.';
|
success.textContent = 'Inquiry received! We will get back to you within 24 hours.';
|
||||||
success.classList.add('form-alert--visible');
|
success.classList.add('form-alert--visible');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user