I\'m using Google reCAPTCHA and have been able to add the CAPTCHA component to my page inside a form. But when I submit the form there\'s no validation taking place to check
I found this to be a quick & easy way to do it. Add this to your headers:
<script>
window.onload = function() {
var recaptcha = document.forms["myForm"]["g-recaptcha-response"];
recaptcha.required = true;
recaptcha.oninvalid = function(e) {
// do something
alert("Please complete the captcha");
}
}
</script>
This only works in HTML5, and is (or should be) supported by these browsers: http://caniuse.com/#feat=form-validation
(The JS console in Chrome shows this error message: "Invalid form control" only in Google Chrome , and I haven't been able to work around this. Hopefully someone else will improve this response.)