I am using laravel 5.8 and i am submitting my form using ajax, and form getting validated using the laravel controller. And if validation fails, in response i get the validation error messages, now i want to show those error messages in the form.
I looked for various solutions and ways to get access to the json response received however i failed to do so.
My Validation Code in User Controller
$this->validate($request,[
'name' => 'required|string',
'email' => 'required|email|unique:users',
'password' => 'required|string|min:6'
]);
and i sent request to store my data using ajax.
So if any validation fails i get response as mentioned below in my network developer tab of chrome :-
{"message":"The given data was invalid.","errors":{"email":["The email has already been taken."],"password":["The password field is required."]}}
So What i want to do is access those error messages and display them below my form. To notify users regarding the errors. However i failed to do so.
Please help me in figuring it out. Thankyou
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire