Laravel 4
When the validation fails return back with the validation errors.
if($validator->fails()) {
return Redirect::back()->withErrors($validator);
}
You can catch the error on your view using
@if($errors->any())
{{ implode('', $errors->all('<div>:message</div>')) }}
@endif
UPDATE
To display error under each field you can do like this.
<input type="text" name="firstname">
@if($errors->has('firstname'))
<div class="error">{{ $errors->first('firstname') }}</div>
@endif
For better display style with css.
You can refer to the docs here.
UPDATE 2
To display all errors at once
@if($errors->any())
{!! implode('', $errors->all('<div>:message</div>')) !!}
@endif
To display error under each field.
@error('firstname')
<div class="error">{{ $message }}</div>
@enderror
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…