Answer the question
In order to leave comments, you need to log in
Why doesn't CF7+Fancybox+reCAPTCHA work?
Good afternoon.
The essence of the problem: the captcha does not work in the modal window (fancybox)
I tried such a script in the header, in functions regarding the fantasybox form, etc.
var onloadCallback = function() {
grecaptcha.render('html_element', {
'sitekey' : 'your_site_key'
});
};
ajax: {
complete: function(jqXHR, textStatus) {
grecaptcha.render('recaptcha', {
sitekey: [RECAPTCHA_SITE_KEY],
callback: function(response) {
console.log(response);
}
});
}
}
Answer the question
In order to leave comments, you need to log in
The problem is solved by the following:
1) We connect the script to the form itself through the CF7 interface
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"
async defer>
var onloadCallback = function() {
grecaptcha.render('recaptcha', {
'sitekey' : 'key'
});
};</script>
onComplete: function(){
//настройки формы cf7, если необходимо
var widgetId = grecaptcha.render('conatiner_id');
grecaptcha.reset(widgetId);
},
$.fancybox({
$.getScript("https://www.google.com/recaptcha/api.js");
onComplete: function(){
$(".captcha_wrapper").append("<div class='g-recaptcha' id='recaptcha' data-sitekey='your_key'></div>");
var widgetId = grecaptcha.render('recaptcha');
},
onCleanup: function(){
$('#recaptcha').remove();
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question