I am using JS Validator to validate my form fields in Laravel
Following is my code in usercontroller for validation
class UserController extends Controller
{
protected $changepassValidationRules = [
'old_password' => 'required|pwdvalidation|min:6',
'password' => 'required|min:6|confirmed',
];
}
I am passing $changepassValidationRules
to view page for checking.
Following is my code in view page
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="card">
<form method="post" action="{{ url('user/changepassword') }}" name="useredit" id="changepass"
enctype="multipart/form-data" novalidate>
{{ csrf_field() }}
@if (session('message_changepass'))
<div class="alert alert-success">
{{ session('message_changepass') }}
</div>
@endif
<div class="card-header">
<h4 class="card-title">
Change Password
</h4>
</div>
<div class="card-content">
<div class="form-group {{ $errors->has('old_password') ? ' has-error' : '' }}">
<label class="control-label">Old Password
<star> *</star>
</label>
<input type="password" placeholder="Password" class="form-control" id="old_password"
name="old_password">
@if ($errors->has('old_password'))
<span class="help-block error-help-block">
{{ $errors->first('old_password') }}
</span>
@endif
</div>
<div class="form-group {{ $errors->has('password') ? ' has-error' : '' }}">
<label class="control-label">New Password
<star> *</star>
</label>
<input type="password" placeholder="Password" class="form-control" id="password" name="password">
@if ($errors->has('password'))
<span class="help-block">
{{ $errors->first('password') }}
</span>
@endif
</div>
<div class="form-group">
<label class="control-label">Confirm Password
<star> *</star>
</label>
<input id="password-confirm" type="password" class="form-control" name="password_confirmation"
placeholder="Confirm Password">
</div>
<div class="form-action">
<button type="submit" class="btn btn-fill btn-info">Submit</button>
</div>
</div>
</form>
</div>
All other validations rules are working perfectly, but issue is that I want to validate current password already in DB.
if user enters a wrong password error should be thrown, what is the problem here
pwdvalidation
? – Dhaval Purohit