0
新しいReCAPTCHAでjQuery検証スクリプトを使用しようとしていますが、ReCAPTCHAが有効であると思われても検証が失敗します。ここに私のコードのストリップダウンバージョンです:有効/無効にかかわらずreCAPTCHAにjQuery検証エラーメッセージが表示されます
<body>
<form id="contact" method="post" action="formmail.php">
<input type="hidden" id="recipients" name="recipients" value="[email protected]" />
<input type="hidden" name="required" value="realname: Your name" />
<input type="hidden" name="derive_fields" value="imgverify=g-recaptcha-response" />
<p><label for="realname">Name</label><br/>
<input type="text" name="realname" id="realname" class="required"/></p>
<label>Are you a robot?</label><br/>
<input type="hidden" class="hiddenRecaptcha required" name="hiddenRecaptcha" id="hiddenRecaptcha">
<div class="g-recaptcha" data-sitekey="6LewiRAUAAAAAF9928pTj2nOoKYyDKA3WpxCoit4" data-callback="recaptchaCallback"></div>
<label class="error" for="hiddenRecaptcha" generated="true"></label>
<p style="margin-top:20px"><input type="submit" value="Submit"></p>
</form>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" type="text/javascript"></script>
<script src="jquery.validate.js" type="text/javascript"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
<script>
jQuery(document).ready(function() {
function recaptchaCallback() {
jQuery('#hiddenRecaptcha').valid();
};
jQuery("#contact").validate({
ignore: ".ignore",
messages: {
realname: "Please enter your full name.",
hiddenRecaptcha: "Please confirm that you are not a robot."
},
hiddenRecaptcha: {
required: function() {
if (grecaptcha.getResponse() == '') {
return true;
} else {
return false;
}
}
}
});
});
</script>
</body>
Hereすると、そのページのライブバージョンです。誰も助けることができますか?
また、recaptchaCallback()関数が必要ですか? –
あなたはそうです、スコット!どうもありがとうございました! –
以前に失敗した試みのためにcaptchaからエラーメッセージを削除するには、recaptchaCallback()関数が必要です。しかし、私はそれをドキュメントレディ機能から外すまで動作しませんでした。 –