I have some forms on the website and google invisible reCAPTCHA. From time to time, something goes wrong and a warning appears: "I can not contact reCAPTCHA. Check the connection and try again." I tried to hide these messages by overriding the warning function:
<script>
var _alert = window.alert;
window.alert = function(text) {
if(text.indexOf("reCAPTCHA") === -1){
_alert(text);
}
return true;
};
</script>
However, this will not work. Alerts are still displayed. This is the code that I use to call reCAPTCHA. I use the real site key instead of MY_SITE_KEY:
<script>
var widgetNewsletter;
var widgetRegistration;
var captchaCallback = function() {
widgetNewsletter = grecaptcha.render('subscriptionSubmit', {
'sitekey' : 'MY_SITE_KEY',
'callback' : function() {
document.getElementById("newsletter-validate-detail").submit();
}
});
if(document.getElementById("registerFormSubmit") !== null) {
widgetRegistration = grecaptcha.render('registerFormSubmit', {
'sitekey' : 'MY_SITE_KEY',
'callback' : function() {
document.getElementById("form-validate").submit();
}
});
}
};
</script>
<script src='https://www.google.com/recaptcha/api.js?onload=captchaCallback&render=explicit' async="false" defer></script>
How can I stop warnings?
source
share