Today, We want to share with you Laravel 6 Required With All Form Validation.In this post we will show you Form Validation Example In Laravel 6, hear for Laravel 6 validation with error message we will give you demo and example for implement.In this post, we will learn about Laravel 6 Form Validation Tutorial Example From Scratch with an example.
Laravel 6 Required With All Form Validation
There are the Following The simple About Laravel 6 Form Validation with Error Messages Full Information With Example and source code.
As I will cover this Post with live Working example to develop laravel form validation before submit, so the laravel validation unique except is used for this example is following below.
List of Laravel validation rules
|
|
|
|
Create Controller Souurce Code
ShopController.php
namespace App\Http\Controllers; use Illuminate\Http\Request; class ShopController extends Controller { public function create() { return view('member-create'); } public function save_data(Request $request) { $input = $request->all(); $request->validate([ 'phone' => 'required_with_all:member_first_name,member_last_name', 'email' => 'required', ]); return redirect()->back(); } }
Create Laravel 6 Blade File
resources\views\member-create.blade.php
<!DOCTYPE html> <html> <head> <title>Laravel 6 - Required With All Validation</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css"/> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <div class="row"> <div class="col-md-6 offset-3"> <div class="card mt-5"> <div class="card-header text-center bg-primary"> <h2 class="text-white"> <strong>Laravel 6 Required With All Validation</strong></h2> <p>PHP Laravel 6 - Required With All Validation Example</p> </div> <div class="card-body"> @if(count($errors) > 0) <ul class="alert alert-danger"> @foreach($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> @endif <form action="{{ route('member.save_data') }}" method="post"> @csrf <div class="form-group dsp"> <label>Member Name :- </label> <input type="text" name="member_first_name" class="form-control tamilrok" value="{{ old('member_first_name') }}"> </div> <div class="form-group dsp"> <label>Last Name :- </label> <input type="text" name="member_last_name" class="form-control tamilrok" value="{{ old('member_last_name') }}"> </div> <div class="form-group dsp"> <label>Phone No. :- </label> <input type="text" name="phone" class="form-control tamilrok" value="{{ old('phone') }}"> </div> <div class="form-group dsp"> <label>Email :- </label> <input type="email" name="email" class="form-control tamilrok" value="{{ old('email') }}"> </div> <div class="text-center tamilrok"> <button class="btn btn-success"><i class="fa fa-floppy-o" aria-hidden="true"></i> Save </button> </div> </form> </div> </div> </div> </div> </div> </body> </html>
Web Programming Tutorials Example with Demo
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about Laravel 6 Validating many input fields on a form before SUBMIT.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, donβt forget to share.