Laravel provides several different approaches to validate your application's incoming data.

Create Routes

routes/web.php : In next step, we will add new two routes in web.php file.

Route::get('/', function () {
    return view('login');

Creating The Controller

Create a controller file UserController.php and save it in the following path app/Http/Controllers/UserController.php.


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class UserController extends Controller {
   public function validation(Request $request) {

Creating The View

Create a view file login.blade.php and save the below code it in resources/views/login.blade.php.

<!DOCTYPE html>
        <title>Login form</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="">
        <script src=""></script>
        <script src=""></script>
        <div class="container">
            <div class="row">
                <form method="post" action="validation">
                    <div class="col-md-6" style="margin-top: 50px">
                        <div class="form-group {{ $errors->has('email') ? 'has-error' : '' }}">
                            Enter Your Email <span class="text-danger">{{ $errors->first('email') }}</span><br/>
                            <input type="text" name="email"class="form-control" />
                        <div class="form-group {{ $errors->has('pass') ? 'has-error' : '' }}">
                            Enter Your Password <span class="text-danger">{{ $errors->first('pass') }}</span><br/>
                            <input type="password" name="pass" class="form-control" />
                        <input type="submit" name="login" value="Login" class="form-control" />

Let us execute this example by the following URL in the browser. This URL may be different based on your website.