[Google reCAPTCHA React] Default value for ReponseStruct.Success is True???
Reactive icon
Forge component by Leandro Oliveira
Application Type

I am new on a project and a bug was reported saying the CAPTCHA didn't work. Turns out we read the response before submitting a form but when the response is never filled (due to the user not checking the box) the value of the success attribute is still true, because that's the default value.

I have now set it to false in my OnInitialize but it should be false by default, right?


Hi Wendy,

I think you misunderstood the Success output parameter. The Google Javascript API is wrapped in client actions executing a Javascript Node with exception handlers. If that JS raises an exception for any reason, e.g. the captcha didn't load,  then the success is set to false, otherwise it's a success (true) operation because no exception was thrown.

Here is the example of the captcha not loading, success = false:

Lastly, did you check the demo?



Thank you for explaining, I have looked at the demo and our case is implemented in the same way as the demo is. 

But I don't understand how to see the difference between a captcha that wasn't loaded and a captcha that wasn't ticked. The same boolean is used to indicate success for both situations, so the value false means either it's not there or the checkbox wasn't ticked. The first situation indicates we should probably reload something and the second situation is handled by the user. 

During testing the captcha apparently didn't load and the user ended up with a message saying they should tick the box, but the box isn't there. How should we solve this?

Theres something strange about your testing, as I said the only situation the boolean returns false is in the case of a exception (ie. the google javascript is not loaded), otherwise its true, even if the checkbox is not ticket. So a captcha that is not loaded (success=false) should return different result from one that is loaded but not ticked (success=true, token=empty).

Anyways, check the Render event to see if the captcha is loaded:

If you can attach your module I'll take a look at it.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.