我遇到reCaptcha数据过期的回调属性的问题。我使用它来通过调用函数来禁用表单中的“提交”按钮。一切正常,在2分钟后该按钮设置为禁用。
问题是reCaptcha复选框保持选中状态。如果我删除data-expired-callback属性,则reCaptcha复选框将清除,并且显示“ verification expired”消息。
请帮助!预先感谢。
... Call API(位于html中)...
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
...
...表单数据...
<form name="rpform" action="" onsubmit="return validateForm()" method="post">
<input type="text" id="sendmail" name="sendmail" value="1">
<div class="g-recaptcha" data-callback="recaptchaCallback" data-expired-callback="reCaptchaExpired" data-sitekey="mysitekeygoeshere"></div>
<div><input type="submit" id="submitBtn" class="submitdisabled" value="please verify that you are not a robot" disabled></div>
</form>
...
... recaptchaCallback js ...
function recaptchaCallback() {
document.getElementById('submitBtn').className = "submitenabled";
document.getElementById("submitBtn").disabled = false;
document.getElementById("submitBtn").value = "Submit";
$('#submitBtn').removeAttr('disabled');
};
...
... reCaptchaExpired js ...
function reCaptchaExpired() {
document.getElementById('submitBtn').className = "submitdisabled";
document.getElementById("submitBtn").disabled = true;
document.getElementById("submitBtn").value = "please verify that you are not a robot";
$('#submitBtn').removeAttr('disabled');
};
...
我希望当超时时间到期时,submitBtn将被禁用,class = submitdisabled且value ='请确认您不是机器人'。这一切都完美地工作。
我还希望reCaptcha复选框能够像往常一样进入其“过期”状态。这不会发生,只是保持选中状态。