I implemented same way but I am getting below error, while am testing in my local host.
Add localhost to the list of supported domains in your reCaptcha configuration at Google's admin console as described here:
https://developers.google.com/recaptcha/docs/faq
Regards,
Thorsten
Maybe you can use one of the Modules from the app store like https://appstore.home.mendix.com/link/app/304/AgileWorks-Information-Systems/reCaptcha-Module