Configure the reCAPTCHA component
mainThe reCAPTCHA component in Form.io can be configured to trigger based on different events: formLoad or buttonClick.
To use reCAPTCHA, you must provide a siteKey within the form's settings.recaptcha object and set isEnabled to 'true'.
Trigger Types
- formLoad: The reCAPTCHA challenge is triggered automatically when the form is loaded. Set
eventType: 'formLoad'in the component configuration. - buttonClick: The reCAPTCHA challenge is triggered when a specific button is clicked. Set
eventType: 'buttonClick'and provide thebuttonKeyof the target button.
const formJSON = {
components: [
{
eventType: 'buttonClick',
type: 'recaptcha',
key: 'reCaptcha',
label: 'reCAPTCHA',
buttonKey: 'test', // The key of the button that triggers the reCAPTCHA
},
{
eventType: 'formLoad',
type: 'recaptcha',
key: 'reCaptcha2',
label: 'reCAPTCHA',
}
],
name: 'testRecaptchaForm',
settings: {
recaptcha: {
isEnabled: 'true',
siteKey: 'YOUR_GOOGLE_SITE_KEY',
},
},
};