在确认我不是机器人复选框后,将显示Java脚本警报“ localhost:12345说空”,然后在警报上单击“确定”,然后单击“提交”按钮,仍然说“ Captcha即使经过验证,也需要验证。
这是我的“与我们联系”页面,即使我得到了最初以为是问题的新钥匙,验证仍然无法进行。 C#
public partial class _default : System.Web.UI.Page
{
classes.Common xCommon = new classes.Common();
classes.Email xEmail = new classes.Email();
protected static string ReCaptcha_Key = "6LczL3QUAAAAAGnY8hnA-hgRjHV0q---------";
protected static string ReCaptcha_Secret = "6LczL3QUAAAAADWlVe0IKVERdq----------";
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_Contact_Submit_Click(object sender, EventArgs e)
{
xEmail.ContactUs_Email(txt_Contact_Name.Text, txt_Contact_Email.Text, txt_Contact_No.Text, ddl_Branch.SelectedItem.ToString(), ddl_Division.SelectedValue,ddl_Type.SelectedValue,txt_Contact_Message.Text, ddl_Branch.SelectedValue);
ltr_MessageReturn.Text = xCommon.Return_Message("contactus", "");
btn_Contact_Submit.Visible = false;
}
[WebMethod]
public static string VerifyCaptcha(string response)
{
string url = "https://www.google.com/recaptcha/api/siteverify?secret=" + ReCaptcha_Secret + "&response=" + response;
return (new WebClient()).DownloadString(url);
}
}
}
JavaScript
var onloadCallback = function () {
grecaptcha.render('dvCaptcha', {
'sitekey': '<%=ReCaptcha_Key %>',
'callback': function (response) {
$.ajax({
type: "POST",
url: "default.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*=rfvCaptcha]").hide();
} else {
$("[id*=txtCaptcha]").val("");
$("[id*=rfvCaptcha]").show();
var error = captchaResponse["error-codes"][0];
$("[id*=rfvCaptcha]").html("RECaptcha error. " + error);
}
}
});
}
});
};
</script>
我希望用户选择所有必需的图像以通过验证然后提交后,验证才能通过。但输出仍然显示需要验证。