首页 > 解决方案 > Laravel - 使用谷歌recaptcha时无法输入错误

问题描述

我在我的登录表单中使用 google recaptcha。我在登录模板中粘贴了脚本标签和代码片段,还添加'g-recaptcha-response' => 'required|captcha',validateLoginAuthenticatesUsers.php. 当我提交表格时,我只收到recaptcha 错误,而不是电子邮件或密码输入!当我删除时,'g-recaptcha-response' => 'required|captcha',我会收到错误!

标签: laravelrecaptcha

解决方案


也许您可以尝试自己设置一个新的验证器(不确定它是否可行,这是一个想法)。

这是此文档部分的链接:https ://laravel.com/docs/5.6/validation#manually-creating-validators

以及附加到操作的控制器文件中的示例:

protected function validator(array $data)
{
    return Validator::make($data, [
        'name' => 'required|string|max:255',
        'email' => 'required|string|email|max:255|unique:users',
        'password' => 'required|string|min:6|confirmed',
        'g-recaptcha-response' => 'required|captcha',
    ]);
}

推荐阅读