ItSolutionStuff.com

Laravel Validation Check If Value is Not Equal to a Another Field

By Hardik Savani • April 16, 2024
Laravel

In this post, we will learn how to check two value must not be same validation in laravel. we can check using laravel different validation rule. you can use different validation rule for field value should not same in form.

You can use that validation with form fields. i will give you controller method with form validation in laravel 6, laravel 7, laravel 8, laravel 9, laravel 10 and laravel 11 application.

This is very small things but it might be need some time to use in laravel application. you can use different validation like as bellow:

Syntax:

different:form_field_name

Example:

different:parent_id

Full Example:

public function mergePost(Request $request)

{

$request->validate([

'primaty_id' => 'required',

'secondary_id' => 'required|different:primaty_id'

]);

dd('You can processed')...

}

I hope it can help you...

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Laravel Country List with Flags Example

Read Now →

How to Show Data in Modal using Ajax in Laravel?

Read Now →

How to Use and Install Font Awesome Icons in Laravel?

Read Now →

How to Read Content from PDF File in Laravel?

Read Now →

How to Remove Public from URL in Laravel 10?

Read Now →

Laravel Calculate Distance Between Two Latitude and Longitude Example

Read Now →

How to Create Widgets in Laravel Application?

Read Now →

How to Get Last Inserted Id in Laravel?

Read Now →

How to Increment and Decrement a Column Value in Laravel?

Read Now →

How to Get Difference Between Two Dates in Laravel?

Read Now →

How to Set URL without Http of Other Site in Laravel?

Read Now →

Laravel CKeditor 5 Image Upload Tutorial Example

Read Now →

Laravel Create JSON File & Download From Text Example

Read Now →