I'm using a jquery repeater plugin and I need to post a json data which is repeater fields data to store method and back that data if there are validation errors. How that is possible?
Asked
Active
Viewed 215 times
3
-
have you try writing any code yet? – Wreigh Aug 14 '18 at 05:02
1 Answers
1
Use laravel builtin validations and it will return you back with errors (if any).
public function store(Request $request){
$validator = Validator::make($request,[
'name' => 'required',
//...
]);
if($validator->fails()){
return response()->json(['errors' => $validator->errors()]);
}
}
jQuery Side validate input on form submit
var name = $('#name').val();
if(name.length < -1){
alert('name is required');
}

Afraz Ahmad
- 5,193
- 28
- 38
-
how about the jquery side? I think that is the OP's main issue although it's not specified in the question. – Wreigh Aug 14 '18 at 05:04