I came here in my search, did not see an answer, and so I kept searching.
After my search, this window was still open, so I am updating this post with my findings.
Here is where you can learn about reCAPTCHA:
http://scraping.pro/no-captcha-recaptcha-challenge/
Basically, though, you add this to your web page:
<script src="https://www.google.com/recaptcha/api.js" >;
<form method="post">
<div class="g-recaptcha" data-sitekey="[site key issued by google]"></div>
<input value="submit" type="submit" />
</form>
To get your reCAPTCHA keys, go to this Google site:
https://www.google.com/recaptcha/intro/index.html
Once you have your keys using the link above, you can get deeper into the coding of this using the following Google information:
https://developers.google.com/recaptcha/
NOTE:
From the Google documentation:
The script must be loaded using the HTTPS protocol and can be included from any point on the page without restriction.
Here is an example of how I got it to work:
<html>
<head>
<title>Contact</title>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<script>
var onloadCallback = function () {
grecaptcha.render('dvCaptcha', {
'sitekey': '<%=ReCaptcha_Key %>',
'callback': function (response) {
$.ajax({
type: "POST",
url: "CS.aspx/VerifyCaptcha",
data: "{response: '" + response + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
var captchaResponse = jQuery.parseJSON(r.d);
if (captchaResponse.success) {
$("[id*=txtCaptcha]").val(captchaResponse.success);
$("[id*=lblAlarm]").hide();
} else {
$("[id*=txtCaptcha]").val("");
$("[id*=lblAlarm]").show();
var error = captchaResponse["error-codes"][0];
$("[id*=lblAlarm]").html("RECaptcha error. " + error);
}
}
});
}
});
};
</script>
</head>
<body>
<form action="?" method="POST">
<div id="dvCaptcha" class="g-recaptcha" data-sitekey="[site key issued by google]"></div>
<br />
<asp:Button ID="btnSubmit" runat="Server" Text="Send" OnClick="btnSubmit_Click" />
<asp:Label ID="lblAlarm" runat="server" ForeColor="Red"></asp:Label>
</form>
</body>
</html>
If you need to validate in the ASP.NET code-behind, simply verify the "g-recaptcha-response" control is filled in:
protected static string ReCaptcha_Key, ReCaptcha_Secret;
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(Request.Form["g-recaptcha-response"]))
{
// other code
} else
{
lblAlarm.Text = "reCAPTCHA failed.";
}
}
Hopefully, some of you find this useful.
$('form input[type=submit]') .before('<div>Are you a human? <input type="checkbox" name="captcha" /></div>');
bots won't check the box because it's not part of the form. jsfiddle.net/s6jkchmz