找到你要的答案

Q:ReCaptcha 2.0: enable Submit button on callback if recaptcha successful

Q:验证码2:使如果reCAPTCHA成功提交按钮的回调函数

I have a very simple form as follows. I want to make it so that the Submit button is disabled, and only enabled after the user has successfully completed the ReCaptcha.

I'm assuming I'm going to need some Javascript / jQuery to do this.

Google's documentation on ReCaptcha 2.0 seems really sparse and dense (to me, anyway). I'd appreciate some pointers:

<form action="something.php" method="post">
    Name: <input type="text" size="40" name="name"><br><br>
    <div class="g-recaptcha" data-sitekey="############-#####"></div>
    <input type="submit" value="Submit" >
</form>

我有一个非常简单的形式如下。我想让提交按钮被禁用,只有启用在用户已经成功地完成了验证码。

我想我需要一些JavaScript、jQuery做这个。

谷歌文档验证码2似乎真的疏与密(对我来说,无论如何)。我会欣赏一些指针:

<form action="something.php" method="post">
    Name: <input type="text" size="40" name="name"><br><br>
    <div class="g-recaptcha" data-sitekey="############-#####"></div>
    <input type="submit" value="Submit" >
</form>
answer1: 回答1:

i did the same thing on my test site. however, i used a button instead of submit, so here:

you must add the property data-callback="enableBtn" data-callback property executes the function specified after accomplishment of recaptcha.

<div class="g-recaptcha" data-sitekey="############-#####" data-callback="enableBtn"></div>

and set the id of the button to whatever id you want to:

<input type="button" value="Submit" id="button1">

On Page load/form load of disable the button

 document.getElementById("button1").disabled = true;

then on javascript make a function to enable the button

 function enableBtn(){
    document.getElementById("button1").disabled = false;
   }

hope it helps.

我在我的测试网站做同样的事情。不过,我用了按钮而不是提交,所以在这里:

你必须添加属性数据回调=“enablebtn”楼市回调函数中指定的数据执行完成后的验证码。

<div class="g-recaptcha" data-sitekey="############-#####" data-callback="enableBtn"></div>

并设置按钮的ID到你想要的任何ID:

<input type="button" value="Submit" id="button1">

在页面加载/窗体加载禁用按钮

 document.getElementById("button1").disabled = true;

然后对JavaScript做功能使按钮

 function enableBtn(){
    document.getElementById("button1").disabled = false;
   }

希望它帮助。

javascript  php  jquery  captcha  recaptcha