Friday, March 31, 2017

How to display SPECIFIC laravel validation error in view, not all of them

The problem I am having is I have multiple validation rules on my date of birth field.

        @if($errors->has('dob'))
            <span id="helpBlock" class="help-block error">
                @foreach($errors->get('dob') as $message) 
                    
                @endforeach
            </span>
            <script>$('#dob').addClass('formError');</script>
        @endif

This will print out ALL of the errors.

I only want to print out the 'required' validation rule if it gets triggered, I am handleing the other validation in the front end.



via gxrobb

Advertisement