'Laravel validator - how to return only errors for certain fields?

I have one form in Laravel in which I have a couple of fields marked as "required" in the validation rules of the controller. When the field is empty, Laravel highlights that field with a red border and adds the is-invalid CSS class (which is good). When the field is filled with anything, it adds a green border and is-valid CSS class.

However, for some fields, I would like to hide the green border when they're filled with something (success response) and only show the red border (failed response) when they're empty.

Is there a way to silence the success response for some fields in the validator rules / controller?



Solution 1:[1]

Your JavaScript code is adding a css class to your inputs like: 'is-valid', 'valid', 'other-valid-class'.

Just control by JavaScript when add the is-valid class.

Check your Script insert in the blade or the @section('scripts').

If in the controller your validations return a fail (on these input) should be shown as red border.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Voxxii