https://github.com/betaweb/formr
A fluent browser-side JavaScript form validator
https://github.com/betaweb/formr
Last synced: about 2 months ago
JSON representation
A fluent browser-side JavaScript form validator
- Host: GitHub
- URL: https://github.com/betaweb/formr
- Owner: betaWeb
- License: mit
- Created: 2017-11-30T17:15:00.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-07-29T12:58:30.000Z (over 5 years ago)
- Last Synced: 2024-04-20T01:40:32.787Z (almost 2 years ago)
- Language: JavaScript
- Size: 53.7 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# formr
An easy-to-use and fluent browser-side JavaScript form validator.
## Easy to install
You just have to download `formr.min.js` and add script tag into your HTML as following :
```HTML
```
## Basic example
#### JS
```JS
var form = document.forms['awesome-form']
var validator = new window.Formr(form)
validator
.required('id', 'title', 'content', 'image')
.string('title', 'content')
.number('id')
.between('id', 1, 10)
.between('title', 1, 5)
.between('content', 10, 2000)
.checked('published', true)
.image('image', ['png'])
.observe({field: 'title', validate: false}, console.log)
.submit(function (e) {
e.preventDefault()
console.log(validator.isValid())
console.log(validator.getErrors())
})
```
#### HTML
```HTML
Envoyer
```