Can anyone give example of confirm password validation?? I am using following way but not working properlly. $arr_validation["rules"] = array(
"password" => "required|confirmed",
"password_confirmation" => "required",
);
$arr_validation["rules_messages"] = array(
"password.required" => "Please Enter password",
"password_confirmation.required" => "Please Enter Confirm Password",
"password.confirmed" => "Confirm password does not metch with password!",
);
$validator = validator::make($arr_form_data, $arr_validation["rules"], $arr_validation["rules_messages"]);
What do you mean by "not working properly"?
@DEVFREY - I have entered same text in password and confirm password textbox though it is giving "Confirm password does not metch with password!" error message
I suggest you double-check your form's HTML. Maybe you have a spelling error in your template.
@KAUSHAL - try this
"password" => "required|confirmed",
"password_confirmation" => "required|same:password",
@kaushal If you are used the confirmed in the password it call the password_confirmation as well, use as like below and check,
$arr_validation["rules"] = array(
"password" => "required",
"password_confirmation" => "confirmed",
);
$arr_validation["rules_messages"] = array(
"password.required" => "Please Enter password",
"password.confirmed" => "Confirm password does not metch with password!",
);
@munazzil That won’t work. If you have the following rule:
return [
'password_confirmation' => 'confirmed',
];
Then Laravel is going to check the value of password_confirmation matches the value of a field named password_confirmation_confirmation.
Docs: https://laravel.com/docs/master/validation#rule-confirmed
@kaushal Your validation should look like this:
return [
'password' => ['required', 'string', 'confirmed'],
];
This will check:
There’s a valid for a field named password.
The value of password matches the value of a field named password_confirmation.
If that’s not working, check what data is actually being passed to your controller:
dd($request->input());
A good candidate for writing a test ;)
Please sign in or create an account to participate in this conversation.