Skip to content

Commit

Permalink
disabling submit button on contact form if captcha isnt complete
Browse files Browse the repository at this point in the history
  • Loading branch information
cullancarey committed Dec 4, 2023
1 parent a6f98ac commit 213232b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,19 @@ <h2>Contact</h2>

<script>
async function submitForm() {

const recaptchaResponse = document.querySelector('textarea[name="g-recaptcha-response"]').value;

// Ensure captcha is complete before submit button is enabled
if (!recaptchaResponse) {
alert("Please fill out captcha.");
// Re-enable the submit button
submitButton.disabled = true;
submitButton.textContent = "Submit";
return;
}


const submitButton = document.querySelector('.btn-primary');
const baseURL = window.location.hostname.includes('develop') ? 'https://form.develop.cullancarey.com/' : 'https://form.cullancarey.com/';
console.log(baseURL);
Expand All @@ -578,7 +591,6 @@ <h2>Contact</h2>
const email = document.getElementById("email").value;
const message = document.getElementById("message").value;
const bot_check = document.getElementById("bot_check");
const recaptchaResponse = document.querySelector('textarea[name="g-recaptcha-response"]').value;

// Perform validation if necessary
if (!name || !email || !message) {
Expand Down

0 comments on commit 213232b

Please sign in to comment.