我试图将reCaptcha添加到Form,但它不会比验证更进一步。请帮忙!
我确实添加了密钥,我确实添加了/php/recaptachalib.php的路径
但不知何故它不起作用,当我输入验证码或错误验证码时,当我点击提交时,没有任何事情发生。
验证码
<form id="another_form" name="another_form" method="post">
<input type="submit" value="Submit Another Form" />
</form>
<div id="recaptchaModal" title="reCAPTCHA" style="display:none;">
<p>Please fill out this reCAPTCHA to submit this form.</p>
<div id="recaptcha_block"></div>
</div>
<script>
$('form').on('submit', function(e){
e.preventDefault();
var formID = e.currentTarget.id;
$("#recaptchaModal").dialog({
modal: true,
resizable: false,
width: 400,
open: function(e, ui){
Recaptcha.create("your_recaptcha_public_key",
"recaptcha_block",
{
theme: "red",
callback: Recaptcha.focus_resonse_field
}
);
},
close: function(e, ui){
Recaptcha.destroy();
},
buttons: {
"Validate reCAPTCHA": function(){
$.ajax({
url: "/url/to/verify/recaptcha",
type: 'post',
data: {
challenge: Recaptcha.get_challenge(),
response: Recaptcha.get_response(),
additional_data: here
},
success: function(data){
if(data != "success"){
alert("The reCAPTCHA wasn't entered correctly. Please try again.");
Recaptcha.reload();
}
else{
//-- submit your form with AJAX + MVC-style
$.ajax({
url: "/your/submission/url/"+formID,
type: "post",
data: $('#'+formID).serialize(),
success: function(data){
//-- forward user to your thank you page
window.location.href = '/url/to/your/thank/you/page/'+formID;
}
});
}
}
});
},
Cancel: function(){
$(this).dialog("close");
}
}
});
});
</script>
</body>
答案 0 :(得分:0)
Captcha是一个防止机器人向表单发送垃圾邮件的脚本,即它验证代理是真人。其次,它通过识别图像中的对象来充当谷歌机器学习的培训 步骤1)转到https://www.google.com/recaptcha/admin#list。
步骤2)选择要添加的验证码类型。
步骤3)选择域的用法。例如,indiaedge.in
步骤4)点击注册。
步骤5)现在您将看到您的站点密钥和密钥。
步骤6)将脚本标记粘贴到页面的头部。
How to add Captcha in Login Form