Вот мое решение
Добавьте ссылку на gap ajax recapcha и создайте капчу.
<script src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js" ></script>
<script type="text/javascript">
function showRecaptcha() {
Recaptcha.create("6LfLrusSAAAAAIoi3XkbGvm2fLao3VjsNTjRoK-K", 'captchadiv', {
tabindex: 1,
theme: "white",
callback: Recaptcha.focus_response_field
});
}
window.onload = function () { showRecaptcha(); }
</script>
HTML-запись
<form id="myform">
<div id="captchadiv">
</div>
<input type="submit" value="Submit" />
</form>
Создание вызова Javascript
<script type="text/javascript">
$('myform').submit(function() {
$.getJSON("someurl/api/ValidateRecapcha", param).done(function (ret) {
if(ret) alert('recacha matched');
else alert('mismatched');
})
})
</script>
Я использую ASP.net Webapi для сервиса и скачал Recaptcha.dll отсюда. https://developers.google.com/recaptcha/docs/aspnet
[HttpGet]
public bool ValidateRecapcha(string challengetKey, string input)
{
var r = new Recaptcha.RecaptchaValidator();
r.PrivateKey = "Recapcha Private Key"
r.Challenge = challengetKey;
r.Response = input;
r.RemoteIP = "REMOTE_ADDR".ToServerVariables();
var response = r.Validate();
return response.IsValid;
}
Надеюсь, это поможет