Google ReCaptcha 2 auto submit

蓝咒 提交于 2019-12-18 08:54:32

问题


My users will see a google repcatcha2 (nocaptcha) in a web page. When they solve the captcha (put the tick in the box) the form should be automatically submit.

Is there any way to do that?


回答1:


Sure you can do it. In this post I've explained how to insert reCaptcha into a site and to code javascript to verify user and site.

  1. Add a name to your form with reCaptcha: <form method="post" name="myform">

  2. Add document.myform.submit(); code for submitting of the form upon the site verification success event:

    <script type='text/javascript'>    
      var onReturnCallback = function(response) { 
        var url='proxy.php?url=' + 'https://www.google.com/recaptcha/api/siteverify';  
        $.ajax({ 'url' : url, 
                   dataType: 'json',
                   data: { response: response},
                   success: function( data  ) {  
                        var res = data.success.toString(); 
                        if (res)
                           { document.myform.submit(); }    
                    }  // end success 
               });  // end $.ajax
    
      };  // end onReturnCallback
    </script>
    


来源:https://stackoverflow.com/questions/32591725/google-recaptcha-2-auto-submit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!