我如何在 HTML 表单提交按钮上验证 Google reCaptcha

How can i vaalidate Google reCaptcha on HTML form submit button

我使用了以下表格: `

<fieldset>
<div class="zl-form-captcha">
    <div class="g-recaptcha" data-sitekey="my-key" style="text-align: center;"></div>
</div>      
</fieldset>

<fieldset>
  <p style="text-align: center;"><button name="submit" type="submit" id="contact-submit" data-submit="...Sending" class="wpcf7-form-control wpcf7-submit btn">Submit</button></p>
</fieldset>

`

如何在提交表单之前验证 google 验证码表单?

谢谢。

您无法在客户端(浏览器)验证验证码,因此您无法在提交前验证它。

验证码验证必须在服务器上完成,在提交表单后,因为它涉及调用 google 和他们的 API 来验证验证码是否已正确回答 请参阅此页面如何进行此验证:https://developers.google.com/recaptcha/docs/verify