How to enable google recaptcha v2 ?

milu_balan
Shopify Partner
60 0 4

Hi,

 

I have enabled recaptcha in the preferences on my client's store but still we are getting a higher number of spams.So I tried integrating recaptcha v2 (checkbox) in the store using the site key. But how to do the server side validation?

I found this piece of code from google search to prevent submission of the form if captcha is not checked.But after displaying the alert ,the form gets submitted. How to do this ?

 

<script>
document.getElementById("ContactForm").addEventListener("submit", function (event) {
var recaptchaResponse = "{{ params['g-recaptcha-response'] }}";

if (!recaptchaResponse) {
event.preventDefault();
alert("Please complete the reCAPTCHA verification.");
}
});
</script>

Reply 1 (1)
milu_balan
Shopify Partner
60 0 4

Can you please help me with the server side code integration ? Is it possible to do it from the contact page liquid file? I tried to get support from the shopify , they suggested to rely on some 3rd party apps.
Any help that could do will be much appreciated.

 

Thanks