ruslanka1987 / invisible-recaptcha
为Laravel的无痕reCAPTCHA。
v1.9.2
2019-06-13 12:23 UTC
Requires
- php: ^5.6.4 || ^7.0
- guzzlehttp/guzzle: ^6.2
- illuminate/support: ^5.0
Requires (Dev)
- illuminate/view: ^5.0
- phpunit/phpunit: ^6.1|^7.0
README
注意
- 此分支用于多表单目的。
- 在大多数情况下,您的页面上应该只有一个验证码。您通常应该使用master分支。
- 不要在单个页面上使用多个验证码以保护每个表单远离机器人,这将导致糟糕的用户体验。
安装
composer require albertcht/invisible-recaptcha:dev-multi-forms
使用示例
// you must include `jquery` beforehand <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> {!! Form::open(['url' => '/', 'id' => 'form1']) !!} @captcha() {!! Form::submit('Sumbit', ['id'=>'s1']) !!} {!! Form::close() !!} {!! Form::open(['url' => '/']) !!} @captcha() {!! Form::submit('Sumbit2', ['id'=>'s2']) !!} {!! Form::close() !!}
在调用验证码之前,请手动包含jquery.js。
直接在表单中调用验证码函数,它将渲染一个验证码,所有表单将共享相同的验证码验证。
<script type="text/javascript"> $('#s2').on('captcha', function(e) { // set it to false if you don't want to submit your from directly _submitAction = false; // do other stuff }); </script>
在此分支中,您可以通过监听验证码事件来自定义提交行为。
示例存储库
存储库: https://github.com/albertcht/invisible-recaptcha-example/tree/multi-forms
此存储库展示了如何使用此包的ajax方式。
差异
- 在此分支中没有
INVISIBLE_RECAPTCHA_DEBUG
配置。 - 此包依赖于
jquery
而不是pilyfill.js
,您必须在调用验证码之前自己包含jquery
。