javascript - 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>
即使输入语句没有得到满足,它也会忽略它并提交表单而不向用户显示错误消息
解决方案
在这里工作正常......
<?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>
推荐阅读
- amazon-web-services - 在无服务器架构/Lambda 上运行 Kafka Producer/Listener 的方法
- node.js - Azure AD 回调 URL 不是每次都被命中
- powerbi - 问:Power BI for Azure Log Analytics/Monitor in Multi-Tenancy Scenario
- sql - 如何用group by查询group by?
- r - 跨组选择最大值 - R/Dplyr 解决方案
- c++ - 包含 C++ INCLUDE 定义的 LUA 文件如何解析和修改?
- isabelle - 为什么在 Isabelle/Isar 证明中需要以下微不足道的自等式?
- ios - 使用按需资源自动上传 iOS AppStore
- python - PyQt5:如何将回溯显示到小部件中?
- android - Flutter in_app_purchase queryProductDetails 方法破坏应用