You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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
      }
    });
  });
});

问题效果

SweetAlert验证提示弹窗

内容的提问来源于stack exchange,提问作者couldnteverbeme

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 14:48:24