0

I have a js

<div id="RecaptchaField" class="RecaptchaField"></div>
<script src="https://www.google.com/recaptcha/api.js?onload=CaptchaCallback&render=explicit" async 
defer></script>
<script type="text/javascript">
var CaptchaCallback = function() {
    grecaptcha.render('RecaptchaField', {
        'sitekey': '6Ldo38kZAAAAAJqvMJMI2R79PHy0fjVDU3QMVHKC'
    });
};
</script>

How can I write it in a phtml file in Magento 2

i have try

 requirejs([
    'jquery'
], function($) {
    var CaptchaCallback = function() {
    grecaptcha.render('RecaptchaField', {
        'sitekey': '6Ldo38kZAAAAAJqvMJMI2R79PHy0fjVDU3QMVHKC'
    });
};
$('body').load(CaptchaCallback );
})
1

1 Answer 1

1

Try this following link :-

https://meetanshi.com/blog/add-google-recaptcha-to-magento-2/

And you want to get extension check this link :-

https://github.com/mageplaza/magento-2-google-recaptcha

THANKS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.