DEV Community

loading...

Discussion on: How to create modal in Laravel 8 and Laravel 6/7 with AJax

faeza97 profile image
Faeza Mohammed • Edited

Look when I erase the input values and submit the form again it won't show the error messages for laravel validator

dev-to-uploads.s3.amazonaws.com/i/...

Thread Thread
christophebossens profile image
Christophe Bossens

Probably a bit late, but if it doesn't help you it might still be useful for other people. I think you are mixing two approaches:

First, you can submit a form by sending a POST request to the server, and the server will then redirect you to a new page. In that case you can use the $errors directive to catch anything that went wrong during validation.

When using a modal, you submit your data using AJAX. This means you basically never leave the page you are on. The server will still return a response, but you have to process this in your JavaScript (specifically, in the AJAX error callback function).

You can find more info here: stackoverflow.com/questions/493337...