Custom laravel validation message


Controller file
/* $this->validate($request, [
  'staples_range' => 'required',
]); */
If you use $this->validate() simplest one, then you should write code something like this..
// using this
$rules = [
 'staples_range' => 'required'
];
$customMessages = [
 'required' => 'The :attribute field is required.'
];
$this->validate($request, $rules, $customMessages);
view file
<textarea name="staples_range" class="form-control" cols="40" rows="box" value="{{ old('staples_range') }}" ></textarea>
@if ($errors->has('staples_range'))    <span class="help-block alert-danger">
    <strong>{{ $errors->first('staples_range') }}</strong>
</span>
@endif





Popular posts from this blog

SQL In Static Id Wise Record Skip After Show Result