Skip to content

Instantly share code, notes, and snippets.

@JamoCA
JamoCA / reCAPTCHA_UDF.cfm
Last active February 5, 2020 18:57
ColdFusion UDF for Google reCAPTCHA v2.0 - Works with CF9. Support for CFX_HTTP5.
<!--- 2/4/2016 isRecaptchaGood
by SunStar Media
Requires this Recaptcha v2.0 JS in the HEAD:
<script src="https://www.google.com/recaptcha/api.js" type="text/javascript"></script>
Requires this to be on the form (at a minimum):
<div class="g-recaptcha" data-sitekey="#Request.Api.recaptcha.SiteKey#"></div>
To validate (if not configured properly, will return true):
isRecaptchaGood(); /* Recommended usage. Uses form parameter, Request.Api.Recaptcha.secret & CGI.Remote_Addr */
isRecaptchaGood(Form["g-recaptcha-response"]);
isRecaptchaGood(Form["g-recaptcha-response"], RecaptchaSecret);