我在下面有这个代码,如果用户未经过身份验证,则会出现此问题"登录"链接:
@if(!\Auth::check())
<span><a id="show_login_modal" href="javascript:void(0)">Login</a>
</span>
@endif
如果用户成功登录,则模态关闭并且用户已进入。其工作正常。
但是如果存在验证错误,例如,如果密码不正确,则关闭模式,用户不会进入,并且不会显示错误消息。对于validaiton消息,必须单击&#34; login&#34;再次打开模态和它上诉&#34;这些凭据与我们的记录不符。&#34;
你知道如果有一个验证错误打开模态而没有必要点击&#34;登录&#34;?
jQuery的:
$('#show_login_modal').click(function(){
$('#login_modal').modal('show');
})
$('#close_login_modal').click(function(){
$('#login_modal').modal('hide');
})
模态:
<div class="modal fade" id="login_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Login</h5>
<button type="button" class="close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="container">
<div class="row">
@include('includes.errors')
<form class="clearfix" method="POST" action="{{ route('login') }}">
{{ csrf_field() }}
<div class="form-group col-12 px-0">
<label for="inputEmail4">Email</label>
<input type="email" class="form-control" value="{{ old('email') }}" name="email" required autofocus placeholder="Email">
</div>
<div class="form-group col-12 px-0">
<label for="inputEmail4">Password
<a href="{{ route('password.request') }}" class="text-gray ml-1" style="text-decoration: underline">
<small>Recover password</small></a> </label>
<input type="password" class="form-control" name="password" required placeholder="Palavra-passe">
</div>
<button type="submit" class="btn btn-primary btn d-block w-100">Login</button>
</form>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" id="close_login_modal" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
errors.blade.php
@if ($errors->any())
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
@endif