gpt4 book ai didi

javascript - 在同一页面上验证多个 recaptcha (V2)

转载 作者:可可西里 更新时间:2023-11-01 02:57:52 25 4
gpt4 key购买 nike

我想知道当同一页面上有多个时,如何验证 Recaptcha 客户端。我找到了这个 https://stackoverflow.com/a/28607943/5649602 ,我有一个就可以了。

但是现在我在每个页面的站点页脚都有一个,在一些注册表中也有一个,所以主题有可能同时出现。

如有任何建议,我将不胜感激。谢谢。 :)

最佳答案

Simplest Way to validate as much g-captcha validate

首先在 </head> 之前包含 api.js标签如下

<script src="https://www.google.com/recaptcha/api.js?onload=CaptchaCallback&render=explicit"></script>

在您的 HTML 中添加此代码

<div class="g-recaptcha-contact" data-sitekey="Your Site Key" id="RecaptchaField2"></div>
<input type="hidden" class="hiddenRecaptcha" name="ct_hiddenRecaptcha" id="ct_hiddenRecaptcha">

<div class="g-recaptcha-quote" data-sitekey="Your Site Key" id="RecaptchaField1"></div>
<input type="hidden" class="hiddenRecaptcha" name="qt_hiddenRecaptcha" id="qt_hiddenRecaptcha">

在页脚中使用 <script> 添加此代码后标记

var CaptchaCallback = function() {
var widgetId1;
var widgetId2;
widgetId1 = grecaptcha.render('RecaptchaField1', {'sitekey' : 'Your Site Key', 'callback' : correctCaptcha_quote});
widgetId2 = grecaptcha.render('RecaptchaField2', {'sitekey' : 'Your Site Key', 'callback' : correctCaptcha_contact});
};
var correctCaptcha_quote = function(response) {
$("#qt_hiddenRecaptcha").val(response);
};
var correctCaptcha_contact = function(response) {
$("#ct_hiddenRecaptcha").val(response);
};

开发人员的最后一个简单步骤如下所示添加 Jquery 验证

$("#form_id").validate({
ignore: [],
rules: {
ct_hiddenRecaptcha: { required: true, },
qt_hiddenRecaptcha: { required: true, },
},
});

关于javascript - 在同一页面上验证多个 recaptcha (V2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40358730/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com