首页 > 解决方案 > html 5 验证不适用于谷歌隐形 recaptcha

问题描述

我之前有一个基本的 Html 5 表单可以正常工作,但是在我添加了 google invisible recaptcha 之后。Html5 验证停止工作。我浏览了很多谷歌,但找不到这样做的方法

<script>
function onSubmit(token) {
document.getElementById("send").submit();
}
</script>

<form  id="send" action="process.php" method="post">
<input type="text" required name="Send" minlength="6" maxlength="16" placeholder="stackoverflow">
<button class="btn btn-primary g-recaptcha" data-sitekey="hidden" data-callback='onSubmit'>Submit</button>
</form>

即使输入语句没有得到满足,它也会忽略它并提交表单而不向用户显示错误消息

标签: javascripthtmlrecaptchainvisible-recaptcha

解决方案


在这里工作正常......

<?php if(isset($_POST['hiddenfield'])){
echo 'submitted';
}
?>

<script>
function onSubmit(token) {
document.getElementById("send").submit();
}
</script>

<form  id="send" action="" method="post">
<input type="hidden" name="hiddenfield">
<input type="text" required name="Send" placeholder="stackoverflow">
<button class="btn btn-primary g-recaptcha" datasitekey="blahblahblahblahblahblahblahblah" data-callback='onSubmit'>Submit</button>
</form>

推荐阅读