Laravel验证码错误提示,后端controller进行验证

编程入门 行业动态 更新时间:2024-10-25 18:33:46

Laravel<a href=https://www.elefans.com/category/jswz/34/1771040.html style=验证码错误提示,后端controller进行验证"/>

Laravel验证码错误提示,后端controller进行验证

前端:

提示:记得 use Validator:

                            <div class="verification"><div class="div user-input"><input placeholder=" 请输入验证码" autocomplete="off" class="code" id="captcha" name="captcha" required><img style="cursor:pointer;width: 120px;height: 38px;margin-left: 10px;" class="thumbnail captcha mt-3 mb-2" src="{{ captcha_src('flat') }}" onclick="this.src='/captcha/flat?'+Math.random()" title="点击图片重新获取验证码">@if ($errors->has('captcha'))<span class="invalid-feedback" role="alert"><strong>{{ $errors->first('captcha') }}</strong></span>@endif</div></div>

后端controller进行验证,错误后返回json数据:

提示:记得 use Validator:

        //验证码验证$rules =['captcha' => 'required|captcha'];$validate = Validator::make($request->all(), $rules); // 此处验证码只能使用validator检测if($validate->fails()){return response()->json(['status' => 500,'error' => '验证码错误']);}

更多推荐

Laravel验证码错误提示,后端controller进行验证

本文发布于:2023-07-28 17:14:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1260047.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:验证码   错误提示   后端   Laravel   controller

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!