Recaptcha plugin

Shows and validates a Google reCAPTCHA v2

Usage

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 Recaptcha plugin:




    


    
...
document.addEventListener('DOMContentLoaded', function(e) { FormValidation.formValidation( document.getElementById('demoForm'), { fields: { ... }, plugins: { ..., recaptcha: new FormValidation.plugins.Recaptcha({ element: 'captchaContainer', language: ..., message: ..., secureToken: ..., siteKey: ..., theme: ..., timeout: ..., }), }, } ); });

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.

Options

Option Type Description
element * String The ID of element showing the captcha
language String The language code defined by reCAPTCHA
message * String The invalid message that will be shown in case the captcha is not valid. You don't need to define it if the back-end URL above returns the message
secureToken String The secure token
siteKey * String The site key provided by Google
theme String The theme name provided by Google. It can be one of
  • light (the default value)
  • dark
timeout String The number of seconds that session will expire. After this amount of time, you will be asked to enter a new captcha. The default value is 120 (2 minutes)

Basic example