From the documentation I understood that in order to change the language of the recaptcha I have to render it explicitly.
The problem is, however, that it's not really showing up, and the onload
is not even called.
When I try to render it automatically it does work.
Here's the code:
In the HTML head: (I have also tried putting this at the end of the body tag)
<script src="https://www.google.com/recaptcha/api.js?onload=recaptchaCallback&render=explicit&hl=iw" async defer></script>
In the HTML form:
<div id="recaptcha"></div>
Javascript:
var recaptchaCallback = function() {
console.log('recaptcha is ready'); // not showing
grecaptcha.render("recaptcha", {
sitekey: 'My Site Key',
callback: function() {
console.log('recaptcha callback');
}
});
}
<script>
tag in yourHEAD
- you can't call theonload
method like that - it needs to go somewhere else, like in your<BODY>
tag.recaptchaCallback
gets defined but when does it get called?onload
parameter in the script URL should state the name of the callback function..../recaptcha/api.js
script using the<SCRIPT>
tag, but call therecaptchaCallback
function using theonload
property of the<BODY>
tag, so it's a 2-part implementation.