My validation not working In Bootstrap Modal using Ajax

you are returning errors with $validator->errors()->all() which will give you an array of error messages with numeric index. it will not use the field name as the index of the array. you have to send it like

return response()->json(['errors' => $validator->errors()]);

this will return an array with filed name as the key and error message as the value (values in array form). and then you can do what are you doing in js end.

if (data.errors.gylight_receipt) {
    $( '#gyReceipt-error' ).html( data.errors.gylight_receipt[0] );

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top