Laravel 5 confirmation error message display in wrong field -
i check if there error in code did not realize why confirmation field's error message keep on displaying in wrong filed? suppose have password field , password_confirmation field, every time when user made mistake in password_confirmation field, error displays in password field instead. here screenshot of error.
and here how validate input using formrequest:
public function rules() { $rules = [ 'login_email' => 'required', 'g-recaptcha-response' => 'required|captcha', ]; if ($this->request->has('password')) { $rules = [ 'password' => 'required|confirmed|between:6,200', 'password_confirmation' => 'required', 'g-recaptcha-response' => 'required|captcha', ]; } if ($this->request->has('old_password')) { $rules = [ 'old_password' => 'required|between:6,200', 'password' => 'required|confirmed|between:6,200', 'password_confirmation' => 'required', 'g-recaptcha-response' => 'required|captcha', ]; } return $rules; }
finally html code
{!! form::open(array('class' => 'form-horizontal login-form', 'url' => url::route('postreset'), 'method' => 'post')) !!} <div class="form-group"> <div class="col-md-12 col-sm-12"> {!! form::password('password', array('class' => 'form-control', 'placeholder' => 'new password*')); !!} {!! messagerservice::setinlineerror($errors->first('password')) !!} </div> </div> <div class="form-group"> <div class="col-md-12 col-sm-12"> {!! form::password('password_confirmation', array('class' => 'form-control', 'placeholder' => 'retype new password*')); !!} {!! messagerservice::setinlineerror($errors->first('password_confirmation')) !!} </div> </div> <div class="form-group"> <div class="col-md-12 col-sm-12"> {!! app('captcha')->display(); !!} {!! messagerservice::setinlineerror($errors->first('g-recaptcha-response')) !!} </div> </div> <div class="form-group"> <div class="col-md-12 col-sm-12"> <button type="submit" class="btn btn-primary cbtn-login">reset password</button> </div> </div> <input type="hidden" name="_token" value="{{ csrf_token() }}"> <input type="hidden" name="hash" value="{{ session::get('hash') }}"> {!! form::close() !!}
because have defined confirmed rule password field, errors related password_confirmation shown in password field.
Comments
Post a Comment