Hi Dev,
Today, i we will show you digits_between validation in laravel 8. This article will give you simple example of digits_between validation in laravel 8. you will digits_between validation in laravel 8. So let’s follow few step to create example of digits_between validation in laravel 8.
Solution:
$request->validate([ 'amount' => 'required|digits_between:1,2' ]);
Add Route:
use App\Http\Controllers\ValidationController; Route::get('digits-between',[ValidationController::class,'digitsBetweenValidation']); Route::post('store-digits-between',[ValidationController::class,'digitsBetweenStore'])->name('store.digits.between');
Controller:
app/Http/Controllers/ValidationController.php
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; class ValidationController extends Controller { public function digitsBetweenValidation() { return view('validation.digitsBetweenValidation'); } public function digitsBetweenStore(Request $request) { $request->validate([ 'amount' => 'required|digits_between:1,2', ]); } }
View:
resources/views/validation/lteValidation.php
<!DOCTYPE html> <html> <head> <title>digits_between Validation In Laravel 8 </title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.3/css/bootstrap.min.css" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" ></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.3/js/bootstrap.min.js" ></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js" ></script> </head> <body> <div class="container mt-5"> <div class="row"> <div class="col-md-8 offset-2 mt-5"> <div class="card"> <div class="card-header bg-info text-white"> <h3>digits_between Validation In Laravel 8 </h3> </div> <div class="card-body"> <form action="{{ route('store.digits.between') }}" method="post"> @csrf <div class="form-group"> <label>Amount :</label> <input class="form-control" name="amount" value="{{ old('amount') }}"> @if($errors->has('amount')) <span class="text-danger">{{ $errors->first('amount') }}</span> @endif </div> <div class="form-group"> <button class="btn btn-success btn-sm">Save</button> </div> </form> </div> </div> </div> </div> </div> </body> </html>
Run:
php artisan serve
I hope it will assist you…