I have attached the code which i am using and while loading the page it is giving me error saying
Cannot contact reCAPTCHA. Check your connection and try again.
Please be remember I'm not going to use any server side code. My website is having simple html.
<html>
<head>
<title>reCAPTCHA demo: Explicit render after an onload callback</title>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<div class="g-recaptcha" data-sitekey="my_site_key"></div>
</body>
</html>
In short you can't. You have to send your site key, secret key and response to the Google API to verify it.
However there is a solution to check if the captcha is filled. When a user solves the captcha there is a element which gets filled named g-recaptcha-response
.
With some javascript you can check if the user has solved the captcha.
var response = grecaptcha.getResponse();
if(response.length == 0)
//reCaptcha not verified
else
//reCaptch verified
However this solution is not a save one. If someone just changes the dom so it looks like the element g-recaptcha-response
is filled it will pass your validation. To be absolute sure the captcha is solved you have to send a API request to Google.
EDIT: Also this question has been asked before (multiple times).
How can I validate google reCAPTCHA v2 using javascript/jQuery?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.