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

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

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
```