I want to design a form but having a trouble about checkbox. After user cliks checkbox, recaptcha will come. When user solves captcha then button will be visible and clickable. Here is my code. How can i make it? Here is an similar problem of my problem, i read it but could not make it work: How to check in js that user has checked the checkbox in Google recaptcha?
<html>
<head>
<title>reCAPTCHA</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript">
var onloadCallback = function() {
grecaptcha.render('html_element', {
'sitekey' : '6LcBb9keAAAAAPo_a4gacC2s0mgufO8K56-NFC5Y'
});
};
</script>
</head>
<body>
<form action="?" method="POST">
<div id="html_element" class="g-recaptcha" data-callback="recaptchaCallback" data-sitekey="6LcBb9keAAAAAPo_a4gacC2s0mgufO8K56-NFC5Y"></div>
<br>
<input disabled type="submit" value="Submit">
</form>
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"
async defer>
</script>
</body>
</html>
<script>
function recaptchaCallback() {
jQuery('#submitBtn').removeAttr('disabled');
};
</script>
Aucun commentaire:
Enregistrer un commentaire