It looks like you want to trigger the reCAPTCHA when clicking "Book Now" and only submit the form if reCAPTCHA passes. From your code, I see you have the correct setup for reCAPTCHA, but you might be missing the crucial part of form submission.
Here's a quick fix:
type="button"
from the "Book Now" button.onSubmit
function to ensure that it submits the form only after reCAPTCHA validation.Here's how you can modify the JavaScript:
<script>
function onSubmit(token) {
document.getElementById("first-form").submit(); // Submit the form after validation
}
</script>
The button should trigger the onSubmit
callback when clicked:
<button
class="g-recaptcha btn btn-primary"
data-sitekey="your-site-key"
data-callback="onSubmit"
data-action="submit">
Book Now
</button>
Make sure you also verify the reCAPTCHA response on the server-side (PHP) by sending the token to Google for validation. Let me know if that clears things up!