Laravel 5.7.8 Validation Errors not showing in contact view

laravel errors not showing
laravel validation
laravel 5.8 form validation
laravel validation unique except
laravel validation exists in table
laravel validation greater than
image validation laravel
laravel validation default value

Using the latest Laravel 5.7.8 and what worked in Laravel 5.6.3 might not be applicable in my case.

I'm trying to create a Contact form validation (required ALERT/SUCCESS messages)




<div id="page">
	<div id="publish">
    <div class="frameterms">
<script src=''></script>
  <div class="notify yellow" style="display:block;">
     {{ Session::get('success') }}

{!! Form::open(['route'=>'']) !!}
<div class="row">
<label>Name<span class="asterix">*</span></label>
<div class="row {{ $errors->has('name') ? 'has-error' : '' }}">

{!! Form::text('name', old('name'), ['class'=>'row', 'placeholder'=>'Enter Name']) !!}
<span class="text-danger">{{ $errors->first('name') }}</span>
<div class="row {{ $errors->has('email') ? 'has-error' : '' }}">
  <label>Email<span class="asterix">*</span></label>
{!! Form::text('email', old('email'), ['class'=>'row', 'placeholder'=>'Enter Email']) !!}
<span class="text-danger">{{ $errors->first('email') }}</span>

<div class="row {{ $errors->has('message') ? 'has-error' : '' }}">
  <label>Subject<span class="asterix">*</span></label>
   <div class="selector">
   <div class="selector1">
  {!! Form::select('subject', array(
    'Select subject...' => 'Select subject...',
    'Web' => 'Web development',
    'Marketing' => 'Marketing',
    'App' => 'App development',
    'Advertising and Promotion' => 'Advertising and Promotion',
    'Other' => 'Other') ) !!}</div>
  <span class="text-danger">{{ $errors->first('message') }}</span>

<div class="row {{ $errors->has('message') ? 'has-error' : '' }}">
  <label>Message<span class="asterix">*</span></label>

{!! Form::textarea('message', old('message'), ['class'=>'row', 'placeholder'=>'Enter Message']) !!}
<span class="text-danger">{{ $errors->first('message') }}</span>

<div class="row">
  <small class="required"><span class="asterix">*</span> Required fields</small>

<div class="form-group {{ $errors->has('g-recaptcha-response') ? ' has-error' : '' }}">
  <div class="col-md-6 pull-center">
  {!! app('captcha')->display() !!}
  @if ($errors->has('g-recaptcha-response'))
  <span class="help-block">
  <strong>{{ $errors->first('g-recaptcha-response') }}</strong>

<div class="rowbutton">
		<input onclick="$('.loader').show(); $(this).hide();" type="submit" value="Send message">
		<div class="loader" style="display:none;"></div>
{!! Form::close() !!}




Update your response as below.

return redirect()->back()->with('success', 'Thanks for contacting us!');

Remove last return as well.

Deep Dive Into Custom Validation Error Messages In Laravel , How do I check if an email is valid in laravel? The problem is that the validator errors don't show up in the view even though I have it coded in. What exactly is going on? Is there some sort of bug in Laravel?

According to Laravel 5.7 Documentation

  return redirect('contact')->with('success', 'Thanks for contacting us!');

After the user is redirected, you may display the flashed message from the session. For example, using Blade syntax:

@if (session('success'))
    <div class="alert alert-success">
        {{ session('success') }}

Validation - Laravel, If sessions are broken, then there wont be any validation errors in the returned session flash. Here is a quick reference tutorial to demonstrate how to display validation errors on view page in Laravel. As you must know that Laravel provides out of the box form / data validation.

Try specifying the view route where you want to show the message like:

return redirect('contact')->with('success', 'Thanks for contacting us!');

And then in your blade view get it like:

@if (session('success'))
    <div class="alert alert-success">
        {{ session('success') }}

Ref: Docs


From your this comment Why the <div class="row"> do not change to <div class="row has-error"> ? it seems you are talking about $errors so what you need to do is check whether error messages exists or not and after that display it like below:

If you want to display error under each field you can do like this.

@if ($errors->has('firstname'))
    <div class="error">{{ $errors->first('firstname') }}</div>

In new version of laravel it is changed to something like if ($errors->any()) However you can refer to docs here.

New Email Validation Rule Options in Laravel 5.8.33, Laravel Version: 5.8.2 PHP Version: 7.2.15 Database Driver & Version: The validation always works (ie the code after the validate() call don't get Btw, I have now also tried simply dd:ing $errors and when the error messages don't display, the Validation methods not populating error bag #31491. Another method to show validation errors in Laravel is by using some tool. These tools can be used for exception handling in Laravel.These tools logs the errors so you can detect the errors as they appear and start fixing them at earliest.

After ContactUS::create($request->all()) line you can use This is my code

    Session::flash('successMsg','what ever you want to message');

    @if( Session::has('successMsg'))
      <p class="btn btn-block btn-success disabled successMsg m-b-30">{{ 
         Session::get('successMsg') }}</p>

make validation like this. USe validator in top. use Validator;

make a validation array which $request you want to verify. Then make verify like this. In else section you write your code . and in if section give a valid message.

$v = [
        'image' => 'image|mimes:png,ico|max:200',
    $validator  = Validator::make($request->all(),$v);
        return redirect()->back();


Laravel 5.7.x, I'm trying to validate a request from form and appear a problem, not showing error messages on the view. The validation succeeds, refreshing the view but not  Displaying The Validation Errors. So, what if the incoming request parameters do not pass the given validation rules? As mentioned previously, Laravel will automatically redirect the user back to their previous location. In addition, all of the validation errors will automatically be flashed to the session.

Ok, if you want to get an error for required fields you must put it like this:

{!! Form::text('name', old('name'), ['class'=>'row', 'placeholder'=>'Enter Name','required']) !!}

The key is 'required' and not like required without ''. I still didn't figure it out how to, do success message properly.

Validation messages not always showing · Issue #27729 · laravel , So, what if the incoming request parameters do not pass the given validation rules Within an @error directive, you may echo the $message variable to display the error message: Also note the call to the route method in the example above. For example, exceptions resulting from 404 errors, as well as several other types of errors, are not written to your log files. You may add other exception types to this array as needed: /** * A list of the exception types that should not be reported.

Why laravel validation don't displaying errors?, if ($validator->fails()) { // The given data did not pass validation }. If validation The errors will also be flashed to the session so they are available for display. If the request Note the call to the route method in the example above. This method  Laravel Version: 5.8.2 PHP Version: 7.2.15 Database Driver & Version: 5.7.25 Description: I've got some kind of strange race condition here I have got a form posting to Laravel.

Error messages are not shown after validation, If validation has failed, you may retrieve the error messages from the validator. that we do not have to explicitly bind the error messages to the view in our GET route. IP Address; Max; MIME Types; Min; Not In; Numeric; Regular Expression​  Laravel 5.2 Form Request Validation Not Showing Errors In View Posted 3 years ago by mikebarwick So, this appears to be a big issue for people upgrading from 5.* to 5.2.

Laravel 6 Form Validation with Error Messages, I want to show error messages after validating of a form . But its not showing the error message when it redirected into previous page . All Laravel controllers use the ValidatesRequests trait which allows you to do If everything goes well you will definitely get the errors as $errors in the view page. Tags : Client side validation Form Validation Laravel Laravel 6 Laravel 6.1 Laravel 6.2 Laravel 6.3 Laravel 6.4 Validation Hardik Savani My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech.

  • can you try my answer?
  • As before, the message is created and sent but, the success cloud does not appear.
  • Did u tried my exact code? Bcz it's working fine on my side
  • Yes exact code! This code work on laravel 5.6. x but not on newer version 5.7.8 Maybe there is a problem in css? : S
  • Why the <div class="row"> do not change to <div class="row has-error"> ?
  • I try it but no success. Still the same.
  • In my previous project on laravel 5.6.3 the <div class="row"> turn to <div class="row has-error"> but here in laravel 5.7.8 stay the same <div class="row"> in HTML inspection
  • Can you do this in blade file var_dump($errors); die();
  • How can I do that? Where exactly?
  • Add this to your blade file <?php var_dump($errors); die() ?> and refresh the page. You might get an error object there. let me know how that object so maybe I can help you.
  • As before, the message is created and sent but, the success cloud does not appear.