Episerver Forms - reCaptcha not working


ive installed the episerver.forms.samples package and added the required javascript in order to get the recaptcha working however when i submit the form, it always returns with the invalid captcha value error

#181366 Aug 16, 2017 22:37

    Is it displaying the reCaptcha element correctly? Could you debug into the validation method ("EPiServer.Forms.Samples.Implementation.Validation.RecaptchaValidator" function) to know anything went wrong?

    #181375 Aug 17, 2017 9:16
  • Member since: 2009

    I don't think you have to add any JavaScript to the page in order to make the recaptchaElement works.

    #181383 Aug 17, 2017 13:34

    After installing the package, i added the code

    <script src="<%: Model.GetExtraResources().First().Item2 %>"></script>
    <script src="<%: Model.GetExtraResources().Last().Item2 %>"></script>

    in order to load in the RecaptchaElementBlock.js and the reCaptcha api. The recaptcha element loads in and show up. 

    However it seems like the validate method never gets called therefore always resulting in invalid captcha value. Am i supposed to call it manually?

    #181395 Edited, Aug 17, 2017 15:51
  • Member since: 2009

    Hi, you don't have to inject any script.

    Recaptcha Element does it himself.

    Have just tested with Forms 4.6.1 and Forms.Samples 3.3.2.

    Sidenote: your site view template should have correct tag for registering client resources, please see it here.

    #181409 Aug 18, 2017 6:18