https://github.com/c-lodder/validatejs-es6
Small, fast and flexible Javascript validation library
https://github.com/c-lodder/validatejs-es6
javascript validate validate-js vanilla-js
Last synced: about 1 year ago
JSON representation
Small, fast and flexible Javascript validation library
- Host: GitHub
- URL: https://github.com/c-lodder/validatejs-es6
- Owner: C-Lodder
- Created: 2018-10-25T11:54:17.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-15T10:36:01.000Z (over 7 years ago)
- Last Synced: 2025-01-29T07:30:01.117Z (over 1 year ago)
- Topics: javascript, validate, validate-js, vanilla-js
- Language: JavaScript
- Size: 35.2 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ValidateJS-ES6
Blazing fast Javascript validation library
# Usage
### Include the validation script on your page:
```
```
or import it:
```
import Validator from "./validate.min.js"
```
Should you require support for Internet Explorer, use `validate-es5.min.js` intead
### Create a simple input field:
```
```
### Basic usage:
```
const Validation = new Validator({
rules: {
// Ensure the property matches that of the input ID
name: {
required: true,
},
},
messages: {
name: {
required: 'Please enter your name',
},
},
errorPlacement: (error, element) => {
alert(error);
// You can append the error to an element below the input or anything else to your liking
}
});
```
### Validate an element
```
const isValid = Validation.validate(document.getElementById('name'));
// Returns true or false
```