我想使用Google Invisible reCAPTCHA,但它發送空的g-recaptcha-response
POST參數時,我在同一頁中有多個窗體。這裏是我的代碼:隱形reCAPTCHA發送多種形式的空g-recaptcha響應
谷歌JS
<script src="//google.com/recaptcha/api.js?hl=pt-BR&onload=captchaCallback&render=explicit" async defer></script>
表1
<form action="/site/Contact/send" id="form1">
<input type="text" name="nome" required>
<div class="g-recaptcha"
data-sitekey="xxxxxxxxxxxxxxxxxxxxxxxx"
data-callback="form1Callback"
data-size="invisible">
</div>
<button type="submit">Send</button>
</form>
表2
<form action="/site/Contact/send" id="form2">
<input type="text" name="nome" required>
<div class="g-recaptcha"
data-sitekey="xxxxxxxxxxxxxxxxxxxxxxxx"
data-callback="form2Callback"
data-size="invisible">
</div>
<button type="submit">Send</button>
</form>
我JS(上this answer如下基於]
$(document).ready(function() {
window.captchaCallback = function(){
$('.g-recaptcha').each(function(index, el) {
var attributes = {
'sitekey' : $(el).data('sitekey'),
'size' : $(el).data('size'),
'callback' : $(el).data('callback')
};
grecaptcha.render(el, attributes);
});
};
window.form1Callback = function(){
$('#form1').submit();
};
window.form2Callback = function(){
$('#form2').submit();
};
});
當我提交的這些形式的g-recaptcha-response
參數發送空單,。
有人可以幫助我把它的工作嗎?
如果答案解決了您的問題,請將其標記爲您接受的答案。這樣世界其他地方就知道哪種解決方案適用於您的特定情況。 – Aram
@Aram,你是對的,但沒有答案能夠解決這個問題,我在這個時候每頁使用單個表單 –