I have a simple contact form built with ASP .Net using the updatepanel. Everything works as expected but i see the error
recaptcha__en.js: Uncaught Error: reCAPTCHA has already been rendered in this element
in the console window
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<script src="https://www.google.com/recaptcha/api.js?onload=pageLoad&render=explicit" async defer></script>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="g-recaptcha" data-sitekey="XXXX"></div>
</ContentTemplate>
</asp:UpdatePanel>
<script language="javascript" type="text/javascript">
function pageLoad() {
$('.g-recaptcha').each(function (index, obj) {
grecaptcha.render(obj, { 'sitekey': 'XXXX' });
});
}
</script>
I initially added onload=pageLoad&render=explicit
as if the captcha was not checked and you clicked the button to send, the captcha disappeared. Adding onload=pageLoad&render=explicit
to the script line resolved this but now i get the above error.
If i try and remove some elements then something else breaks i.e. captcha doesnt display or is not displayed on postback?
<script src="https://www.google.com/recaptcha
twice on the page? Check the html to be sure. – Plaque