BoxLang 🚀 A New JVM Dynamic Language Learn More...

Recaptcha Google v3.0

v3.0.0 Modules

ColdBox ReCAPTCHA Google v3.0 Module

This module contains helpers for using Google's ReCAPTCHA API.

reCAPTCHA is a free service that protects your site from spam and abuse. It uses advanced risk analysis techniques to tell humans and bots apart.

reCAPTCHA v3 returns a score for each request without user friction. The score is based on interactions with your site and enables you to take an appropriate action for your site. Register reCAPTCHA v3 keys here:


Apache License, Version 2.0.


  • Lucee 5+
  • ColdFusion 11+
  • ColdBox 5+


Just drop into your modules folder or use the CommandBox to install

box install recaptcha3



Get an API key pair at and add the following settings to your Coldbox.cfc under a recaptcha3 structure within the moduleSettings structure:

moduleSettings = {
	// recaptcha settings
	recaptcha3 = {
    	secretKey 	= "Secret key",
    	publickey 	= "Site key",
    	score       = 0.5, // "Minimum score (0 to 1)"

Rendering Recaptcha

In any form you wish to add the reCaptcha widget which is a button with the invisible reCaptcha embedded.

Here is an example of usage:

		id = "button-id",
		label = "Your Label",
		class = "text-center",
		callbackFunction = "onSubmit",
		loadRecaptchaApi = "true"

The arguments the widget receives are the following arguments:

  • id -> optional argument to set an id to the button so you can manipulate it via css/js

  • label -> It can be any text you want and will be used as the label for your button.

  • class -> The class that will be applied to the button element.

  • callbackFunction -> The callback function to handle the token.

    function onSubmit(token) {
  • loadRecaptchaApi -> a true/false flag (defaults to false) if you want to delegate the widget the task to load the javascript api, otherwise you will have to do it yourself in your layout like so:

 < script src=""></script>


Validation can be done manually or using or custom validator that leverages the cbValidation module (

Custom Validator

In your handler for the post of the form, or in a model object you can then use the included Validator. Here is an example of using it in a model object:

this.constraints = {
	"body" 	: { required : true },
	"recaptcha" : { validator: "Validator@recaptcha3" }

In the above example, your handler would just need to set the recaptcha property on the model object to the g-recaptcha-response value that is part of the form payload.

Manual Validation

There also is a RecaptchaService@recaptcha3 Wirebox mapping you can use to validate manually if you prefer to not use the cbvalidation integration. In your handler:

var recaptchaOK = getInstance( "RecaptchaService@recaptcha3" ).isValid( rc[ "g-recaptcha-response" ] );

if ( !recaptchaOK ){
    writeOutput( "Prove you have a soul!" );



  • Initial commit


  • Docs and repo updates


  • Widget update
  • Add more args to customize the button
  • New loadRecaptchaApi flag to load the javascript api in the widget or not


  • Rename module package to be recaptcha3 to keep consistency


  • Add score to the module settings and validate it against the google response

$ box install recaptcha3

No collaborators yet.
5.00 / 1
  • {{ getFullDate("2021-10-28T16:24:37Z") }}
  • {{ getFullDate("2024-06-07T15:33:05Z") }}
  • 3,665
  • 1,827