Laravel 5 Tutorial : How to use Validation in Laravel 5.3

Laravel 5.3 tutorials for beginner : How to use Validation in Laravel 5.3 apps? How to make laravel 5 using validation example in laravel 5.3

Laravel 5.3 - Validation, Validation in laravel 5.3 or at the all applications is the most important aspect while designing of them. It validates the incoming data. By default, base controller class uses a Validates Requests trait which provides a convenient method to validate incoming HTTP requests with a variety of powerful validation rules.

At the last Lessons, we have learn about Forms & HTML Class in laravel 5.3 and localization for Multiple languages in laravel 5.3

How to use Validation in Laravel 5.3

In your Laravel 5.3 project, create new Controller using Artisan CLI following this command

php artisan make:controller ValidationController

your new controller ValidationController has created and stored on app\Http\Controllers\Validation.php

add some function in our ValidationController.php

ValidationController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

class ValidationController extends Controller
{
    // create new function to show the form login as a our index
    public function ShowForm(){
      return view('loginex');
    }
    // create function for our Validation
    public function ValidateForm(Request $request){
      print_r($request->all());
      $this->validate($request,[
          'username'=>'required|max:10',
          'password'=>'required'
      ]);
    }
}

Now, create new views to show our Login form, that stored on resources\views, at the preview Lessons, we have learn about Authentication Login & Registration Form + Bootstrap in laravel 5.3.

How to use Validation in Laravel 5.3

loginex.blade.php

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Validate Login</title>
  </head>
  <body>

    @if (count($errors) > 0)
      <div class="error">
        <ul>
          @foreach($errors->all() as $error)
            <li>{{ $error }}</li>
          @endforeach
        </ul>
      </div>
    @endif

    <?php
      echo Form::open(['url'=>'/validation']);
     ?>
     <table border="1">
       <tr>
         <td>
           Login
         </td>
       </tr>
       <tr>
         <td>
           username
         </td>
         <td>
           <?php echo Form::text('username'); ?>
         </td>
       </tr>
       <tr>
         <td>
           Password
         </td>
         <td>
           <?php echo Form::password('password'); ?>
         </td>
       </tr>
       <tr>
         <td>
           Password
         </td>
         <td>
           <?php echo Form::submit('login'); ?>
         </td>
       </tr>
     </table>
     <?php echo Form::close(); ?>
  </body>
</html>

Next, create new routes that stored on \routes\web.php

web.php

Route::get('/validation', 'ValidationController@ShowForm');
Route::post('/validation', 'ValidationController@ValidateForm');

Next, try to access our validation on your browser following this command

http://localhost:8080/validation

Video Tutorial How to use Validation in Laravel 5.3



See you next Lessions ...

COMMENTS


Feel free to code it up and send us a pull request.

Hi everyone, let's me know how much this lesson can help your work. Please Subscribe and Follow Our Social Media 'kodeajaib[dot]com' to get Latest tutorials and will be send to your email everyday for free!, Just hit a comment if you have confused. Nice to meet you and Happy coding :) all ^^



Follow by E-Mail


Name

ADO.NET,3,Ajax,6,Android,9,AngularJS,4,ASP.NET,4,Blogger Tutorials,7,Bootstrap,7,C++,1,Codeigniter,2,Cplusplus,6,Crystal Report,6,CSharp,25,Ebook Java,2,FlyExam,1,FSharp,3,Game Development,2,Java,35,JDBC,2,Laravel,89,Lumen,2,MariaDB,2,Ms Access,3,MySQL,31,ODBC,6,OleDB,1,PHP,14,PHP Framework,6,PHP MYSQLI,9,PHP OOP,5,Python,8,Python 3,4,SQL Server,4,SQLite,4,Uncategorized,5,Vb 6,2,Vb.Net,89,Video,48,Vue Js,4,WPF,2,Yii,3,
ltr
item
KODE AJAIB: Laravel 5 Tutorial : How to use Validation in Laravel 5.3
Laravel 5 Tutorial : How to use Validation in Laravel 5.3
Laravel 5.3 tutorials for beginner : How to use Validation in Laravel 5.3 apps? How to make laravel 5 using validation example in laravel 5.3
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgo6xN45v42p2lqYe_6MAu_TRjtxDQDZ0eEWuumhp8iYtjIL1hcZkARyS0hbzMpLWLlalEDSSTeSE3b_DarQCY5Ep01aHxST4Sgc4tdcz8URtK_xf_eWTF0TFE7rK0W-B0FfyF5gAIi8e0/s320/laravel-tutorial-for-beginner.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgo6xN45v42p2lqYe_6MAu_TRjtxDQDZ0eEWuumhp8iYtjIL1hcZkARyS0hbzMpLWLlalEDSSTeSE3b_DarQCY5Ep01aHxST4Sgc4tdcz8URtK_xf_eWTF0TFE7rK0W-B0FfyF5gAIi8e0/s72-c/laravel-tutorial-for-beginner.png
KODE AJAIB
https://scqq.blogspot.com/2016/09/laravel-5-how-to-use-validation.html
https://scqq.blogspot.com/
https://scqq.blogspot.com/
https://scqq.blogspot.com/2016/09/laravel-5-how-to-use-validation.html
true
3214704946184383982
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy