https://github.com/torann/jquery.validation
Simple form validation using the Laravel validation syntax.
https://github.com/torann/jquery.validation
Last synced: about 1 month ago
JSON representation
Simple form validation using the Laravel validation syntax.
- Host: GitHub
- URL: https://github.com/torann/jquery.validation
- Owner: Torann
- License: other
- Created: 2017-11-08T15:33:09.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-29T20:38:45.000Z (almost 7 years ago)
- Last Synced: 2025-02-15T05:43:43.950Z (3 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jQuery Validation
Simple form validation using the Laravel validation syntax.
## Getting started
The form containing the inputs that need validation must inlcude the class `js-validate`. This helpers cut down some on the walking the DOM.
### Data Tags
#### `data-validate=":rules"`
This attribute is on the form element that is being validated. It contains the rules used to validate.
#### `data-validate-msg=":rule"`
This attribute is attached the the tag that is used inside of the input group and contains the translated values for the errors. The attributes value indicated the rule that failed.
## Rules
#### accepted
The field under validation must be *yes*, *on*, *1*, or *true*. This is useful for validating "Terms of Service" acceptance.
#### alpha_num
The field under validation must be entirely alpha-numeric characters.
#### between:*min*,*max*
The field under validation must have a size between the given *min* and *max*.
#### date
The field under validation must be a valid date according to the `YYYY-MM-DD` or `YYYY/MM/DD`.
The field under validation must be formatted as an e-mail address.
#### in:*foo*,*bar*,...
The field under validation must be included in the given list of values.
#### max:*value*
The field under validation must be less than or equal to a maximum *value*.
#### min:*value*
The field under validation must have a minimum *value*.
#### not_in:*foo*,*bar*,...
The field under validation must not be included in the given list of values.
#### required
The field under validation must be present in the input data and not empty.
#### time
The field under validation must be a valid time string.
#### unique:*endpoint*,*except*
The field under validation must be unique. The `endpoint` is used to create the validation AJAX url `/ajax/:endpoint/check/:field`.
## Example
```html
Select Country
United States
United Kingdom
A country must be selected.
A city must be entered.
The city name has a max character length of 255.
```## Required Functions
**Translation**
[jQuery Translation](https://github.com/Torann/jquery-translation)
**Snackbar**
This is built to use a simple snackbar helper function:
```
$.snackbar({
message: 'Message from the panel event',
style: 'error',
timeout: null
});
```