Laravel validation required if another field is empty

Hello Dev’s Now In this artical, i will give you a short and simple example of laravel in validation required when another field is empty.

So we know that laravel provide us several in-built laravel validation required_without . If we need to add validation rules like required when another other field is empty in laravel then we can do it by using required_without.

So now I am going to explain with you, If we can not enter test (field) value at that time test1 (field) is required. So at that time we can add validation required_without.

So, you can use this way:

	"test1" =>"required_without:test"


public function store(Request $request)
   	  "test" =>"required",
   	  "test1" =>"required_without:test"


It return validation error otherwise it show Done!.

Read Also : How To Get Current Page Url in Jquery ?


About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →