reCAPTCHA not working



I am attempting to add reCaptcha to a form on our episerver site. I have done the following:

  • installed nuget package for Episerver.Forms.Samples - this allows the widget for recaptcha to now show as an option in cms
  • registered w/ google for the site key and secret key 
  • added script link in my root cshtml file 
  • <script src="" async defer>
  • When I save the reCaptcha form element w/ site key and secret key added it doesn't give me any error. However the form has no "I'm not a robot" on it. When I attempt to save the form, it says invalid captcha value. Console error says, missing site key (api.js). I notice that in the source view, the site key is actually displaying as epiforms-sitekey instead of just sitekey. 

Is there additional javascript I am to include in my solution beyond just including the reference to googles api.js? how can I get the recaptcha element I drop on my form to actually render the "I'm not a robot" message as desired?

currently the forms.samples package is version 3.5.0 and episerver.forms is 4.27.0

thank you for any assistance!

Feb 21, 2020 19:40

Hi LauraK,

Have you tried without having the script added to your root file? We've implemented reCAPTCHA in much the same way, but we didn't have to manually add the api.js script, the form element from EPiServer.Forms.Samples did that for us.


Feb 24, 2020 11:11

Hi Alex Brown

Thank you for the reply! I tried removing the script include (so now it's just the package itself) and I see the same behavior. no "I'm not a robot" and when trying to submit, "Invalid Captcha value". However without the script include I don't see the console error from the api.js library.

Thank you,


Feb 24, 2020 14:59

hmm... how have to got reCAPTCHA configured in the Admin Console? Is your reCAPTCHA type 'v2 checkbox'?

Feb 24, 2020 15:04

It doesn't ask.. that's what is strange. Basically I add the recaptcha widget and edit it, and the only "settings" it asks for is site key and secret key. 

All I added was Forms.Samples though through nuget package manager, maybe I'm just missing important steps? Clearly it "took" the package, becasue prior to adding the package reCaptcha wasn't an option under Form elements and now it is. 

Feb 24, 2020 15:20

Sorry, I mean on

Feb 24, 2020 15:23

oh wait, did you mean admin console on Google? sorry for the confusion! Yes it's set to v2 Checkbox as the type. 

Feb 24, 2020 15:23

Can you see RecaptchElementBlock.js and api.js?onload=initRecaptch.... being loaded onto your page?

Feb 24, 2020 15:42

perhaps an adblocker preventing recaptcha from loading?

Feb 24, 2020 15:46

Hi Alex

I do not think it is loading- i just noticed in the form on page editing view it says reCAPTCHA: Javascript is required to display reCAPTCHA

But then when I include the javascript library in root, it gives me the console error. 

When you say ad blocker, how can I investigate if that is happening? we do have plenty of other javascript libraries in use on our site, also we used CAPTCHA with success before and are using CAPTCHA in production.

It seems to me like I am supposed to include javascript somewhere but then others say they include the nuget package and that takes care of everything so I am confused.

Thank you again for your assistance!


Feb 24, 2020 16:08

We get the same message about javascript when looking at the form via OPE. So I wouldn't worry about that.

Re Adblocker, I just wondered if you were using one in the browser which is stopping the recaptcha javascript from loading. Perhaps a Chrome extension or FF built in adblocker?

I would expect to see two things on your page:

1) In the DOM you should see EPiServer.Forms scripts loading in some external files, which should include 


2) Those external files being loaded into the page:

Are you able to see those things?

Feb 24, 2020 16:23

Hi Alex

no, I don't see those - it seems all I can see in the source is the div for recaptcha rendering, and then on submit of the form, the  div contains the invalid captcha message. But I don't see any javascript files loading that appear to relate to recaptcha. 

<div class="Form__Element Form__CustomElement FormRecaptcha" data-epiforms-element-name="__field_24243" data-epiforms-sitekey="MYSITEKEY" id="THEGUID">

<div class="g-recaptcha"></div>
<span data-epiforms-linked-name="__field_24243" class="Form__Element__ValidationError" style="display:none;"></span>


Inside the getFormInitScript that loads on the episerver.forms/datasubmit I do see a reference to EpiServer.Forms.Samples.implementation.Validation.RecaptchaValidator with the message for recaptca value being invalid, but no scripts appear to be loading to actually render the recaptcha? Maybe I should remove the package, re-add it and rebuild?  

Thank you,


Feb 24, 2020 17:17

Wait! I think I have "solved" it. Well at least, I noticed we are also having some kind of strange console js error on the form - "epi" is not defined. Now we also have this problem on production which doesn't appear to actually cause any issue (production forms work).

But I was looking into the solution for that console error as i only noticed it when investigating reCaptcha problems. When I resolved that error, now my recaptcha just works as expected!

thank you for the assistance Alex! I really appreciate you taking the time.

Feb 24, 2020 19:52
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.