Shows and validates a Google reCAPTCHA v3
TipUse the Recaptcha plugin if you are still using Google reCAPTCHA v2
To use it, you need to register a site and secret keys at https://www.google.com/recaptcha/admin.
The following piece of code is the starting point to use the Recaptcha3 plugin:
The sample code above assumes that the FormValidation files are placed inside the
vendors directory. You might need to change the path depending on where you place them on the server.
* presents a required parameter
| ||String||The page action|
| ||String||The URL of your back-end that verifies the captcha via reCAPTCHA API|
| ||String||The ID of element showing the captcha|
| ||String||The language code defined by reCAPTCHA|
| ||String||The invalid message that will be shown in case the captcha is not valid|
| ||String||The site key provided by Google|
For testing purpose, the back-end verification always indicates that the captcha is valid.
The plugin also requires verification on the server side. You need to point the
backendVerificationUrl option to your back-end URL:
When click the Submit button, the plugin will send an Ajax request with the value for
___g-recaptcha-token___ parameter which is generated by reCAPTCHA. With the value of captcha token and the reCAPTCHA secret key, you can connect to reCAPTCGA verification URL to verify the captcha.
In order to inform user in case the captcha is valid or invalid, the back-end has to return a JSON encoded version of
The following code demonstrates how to do it in PHP, but you can do it with your favorite language.
- v1.5.0: First release. It means that the Recaptcha3 plugin requires FormValidation v1.5.0 or newer.