我有一個使用以下行PHP腳本集成驗證碼提交表單:與現有的PHP腳本
<form action = "javascript:void(null);" onsubmit = "load_ajax();" name = "myform">
現在,保護機器人從濫用我想要實現的reCAPTCHA如這裏所描述的形式:
http://www.darksideofthecarton.com/2008/12/15/validating-recaptcha-with-jquery-and-ajax/
reCAPTCHA邏輯工作正常,顯示驗證成功/失敗的消息,但表單沒有被提交。下面是我使用使用reCAPTCHA代碼:
<form action = "javascript:void(null);" onsubmit = "return validateCaptcha()" name = "myform">
裏面我是用打電話給我load_ajax()函數(表示成功的表單提交)
驗證部分:
function validateCaptcha()
{
challengeField = $("input#recaptcha_challenge_field").val();
responseField = $("input#recaptcha_response_field").val();
//alert(challengeField);
//alert(responseField);
//return false;
var html = $.ajax({
type: "POST",
url: "ajax.recaptcha.php",
data: "recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField,
async: false
}).responseText;
if(html == "success")
{
$("#captchaStatus").html("Success. Submitting form.");
return false;
// Uncomment the following line in your application
load_ajax();
return true;
}
else
{
$("#captchaStatus").html("Image verification failed, Pls. enter the image verification code correctly.");
Recaptcha.reload();
return false;
}
}
</script>
我不是PHP/JavaScript專家,所以需要幫助。
謝謝
我仍然無法相信人們不知道如何悄悄地實現jQuery的。 '