ReCaptcha集成SweetAlert后,勾选验证仍提示需确认非机器人
ReCaptcha集成到SweetAlert弹窗后验证不生效问题
我已将ReCaptcha集成到SweetAlert弹窗中,但勾选“我不是机器人”的验证框后,SweetAlert仍弹出“请验证您不是机器人”的提示。我已根据Aahan Agarwal的回复更新了代码,也按照SweetAlert食谱网站的文档实现弹窗集成ReCaptcha,但脚本无法正常执行,弹窗依旧提示需验证身份。
相关代码
HTML触发代码
<form id="request_quote" method="POST" action="quoterequest.php"> <input type="hidden" id="...." value="..."> <button id="quoteButton" class="mt-4 qbutton btn btn-outline-primary" type="submit">Request Print</button> </form>
JavaScript代码
$(document).ready(function() { $("#request_quote").submit(function(e) { e.preventDefault(); Swal.fire({ title: 'Please enter your email', input: 'email', inputAttributes: { autocapitalize: 'off' }, html: '<div id="recaptcha"></div>', didOpen: () => { grecaptcha.render('recaptcha', { 'sitekey': 'SITE_KEY' }); }, preConfirm: function () { if (!grecaptcha.getResponse()) { Swal.showValidationMessage(`Please verify that you're not a robot`); } } }).then(function(result) { if (result.isConfirmed) { ...rest of code } }); }); });
问题效果

内容的提问来源于stack exchange,提问作者couldnteverbeme
相关产品推荐
相关产品推荐

