php - How to make recapcha v2 a required field in html form?
Get the solution ↓↓↓I'm having issues with adding a recaptcha to my html form. the widget is displayed and works properly, the problem is the send button is working even when the recaptcha isn't validated. Can someone help me understand what to do to fix this?
I followed the docs on google's guide and all I did was add the following. Is something missing? This is my first ever website so I'm a bit of a noob, could someone tell me if i need to add anything? :')
<head>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<form>
<div class="g-recaptcha" data-sitekey="my_site_key"></div>
</form>
Answer
Solution:
You can use a callback. Please make a button disabled as a default state. And then you need to enable it in callback function.
var onloadCallback = function () {
grecaptcha.render('captacha', {
'sitekey': '<?php echo $secret_client ?>',
'callback': verifyCallback,
'theme': 'light'
});
};
var verifyCallback = function (response) {
$('#btn-register').attr('disabled', false);
};
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: ftp_put(): can't open that file: no such file or directory
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.