Episerver Forms - reCaptcha not working | Episerver Developer Community

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
  •  

    Hi,

    I am stuck with a similar situation. ive installed the episerver.forms.samples package and added the required javascript in order to display the recaptcha.

    however when i submit the form, it always returns with the invalid captcha value error.

    I have debugged into the validation method ("EPiServer.Forms.Samples.Implementation.Validation.RecaptchaValidator" function) and could find that that the GetSubmitted value function is returning null.

    submitData = HttpContext.Current.Request.HttpMethod == "POST" ? HttpContext.Current.Request.Form : HttpContext.Current.Request.QueryString;
    submitData["g-recaptcha-response"] is always null.

    #195751 Edited, Aug 07, 2018 11:19
  • Member since: 2009
     

    Hi, you don't have to add any script in order to use RecaptchaElement. See my previous post.

    https://world.episerver.com/forum/developer-forum/episerver-forms/thread-container/2017/8/episerver-forms---recaptcha-not-working/#181409

    #195754 Aug 07, 2018 11:46
  •  

    Hi,

    The captcha element is getting displayed but in the validator the submitted value is comming as null.

    #195757 Aug 07, 2018 12:27
  •  

    Hi,

    I've verified the Forms Samples package 3.4.0 and it is working. Can you try with new fresh AlloyMVC site to make sure there is no custom code invoked during the submit process? 

    #195797 Aug 08, 2018 5:03
  •  

    Hi Halima,

    Please check your API keys Register Google API Keys

    I've tried using Forms ver 4.11 along with Forms.Sample and it is still fine.

    /Quan

    #195800 Aug 08, 2018 5:38