Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bitnbytesio/jvalidator

Client Side validation in Laravel
https://github.com/bitnbytesio/jvalidator

Last synced: about 1 month ago
JSON representation

Client Side validation in Laravel

Awesome Lists containing this project

README

        

# jQuery validator for Laravel 5

This package will provide both client and Server Side validation for laravel 5.

**Dependency**
- Laravel 5
- Jquery 1.11+
- Jquery Validation 1.14

**Usage**
```html





{{csrf_field()}}



name


email


age


website


price


highlight_text


display_name


newsletter
True False


terms




{!! $jquery->validate("#form-sample"); !!}

```

```php

// routes.php

Route::any('test', function () {

// validation rules
$r = [
'name' => 'required',
'age' => 'required|min:18|max:21',
'email' => 'required|email',
'i_agree' => 'accepted',
'website' => 'required|url',
'display_name' => 'required|alpha|between:5,6',
'price' => 'required|between:100,200',
'highlight_text' => 'required|between:20,40',
'newsletter' => 'required|boolean'
];

// custom messages
$m = [
'required' => 'The field can\'t be left blank',
'age.min' => 'You must be 18 yrs old',
'age.max' => 'You must be under 23 yrs',
];

$v = new Artisangang\Validator\Validator($r,$m);
if (Input::has('name')) {
$l = $v->make(\Input::all());
var_dump($l->errors());
}

return view('index');

});

```