I have small laravel project and trying now on input validation using request. Below is my request file.
public function rules()
{
return [
'name' => 'required',
'genericname' => 'required'
];
}
public function messages()
{
return [
'name.required' => 'Name required',
'genericname.required' => 'Genericname required'
];
}
My blade template work as normal to show flash once errors found as below code.
@if ($errors->count() > 0)
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
{{ $errors->first() }}
</div>
@endif
But my concern is that, Is it possible to call javascript instead if errors found. For example of my need
@if ($errors->count() > 0)
{{ callJavaScriptAlertFunction() }}
@endif
Any advise or guidance would be greatly appreciated, Thanks.