Validate Google reCAPTCHA with jQuery

There are two ways to validate Google reCAPTCHA, In PHP and jQuery but here we show you how to validate with jQuery.

 

// validate google reCAPTCHA
var response = grecaptcha.getResponse();
if (response.length == 0) {
    $('#msg').addClass('text-danger');
    $('#msg').html('Please click on the reCAPTCHA box.');
    return false;
}

 

We used grecaptcha object and bind the getResponse() to validate the reCAPTCHA. if response length is equal to zero than means user did not checked the reCAPTCHA.

 

Was this post helpful?
Let us know if you liked the post. That’s the only way we can improve.
Yes1
No0
Harinder Singh

Harinder Singh

My name is Harinder Singh and I specialize in Software industry. I consider myself as a life learner. I love learning new concepts, embracing new ideas and reading and searching for innovation.