在reCAPTCHA v3的此示例中,g-recaptcha-response文本区域位于表格之外...
<form method="post">
<input type="text" name="name" placeholder="Name">
<input type="text" name="email" placeholder="E-Mail">
<script type="text/javascript">
var onloadCallback = function() {
console.log('onloadCallback');
grecaptcha.execute(
"SITEKEY",
{action: "homepage"})
.then(function(token) {
console.log('verifyCallback')
console.log(token);
}
);
};
</script>
<script src="https://www.google.com/recaptcha/api.js?render=SITEKEY&onload=onloadCallback"></script>
<input type="submit" value="Send">
</form>
因此没有$_POST["g-recaptcha-response"]
要在表单标签内提供文本区域,需要进行哪些调整?
答案 0 :(得分:0)
您需要表单中用于接收响应的隐藏输入,还需要将令牌设置为隐藏输入值
<input type="hidden" id="g-recaptcha-response" name="g-recaptcha-response" value="" />
document.getElementById('g-recaptcha-response').value = token;
但是,我在Magento 2中的recaptcha v.3实施中也遇到了问题。