Very simple universal input validation module
npm install input-validation
> Very simple universal input validation module
This module has zero dependencies, is extensible and uses data attributes to target validation conditions
``bash
npm install input-validation
`
`javascript
var validatior require('input-validation'),
handlers = {
blur: function(target) {
target.className = validator.validate(target) ? '' : 'invalid';
}
}
`
`html
`
- data-required
The user must supply some value to for the input to be valid
`html`
- data-valid-email
The user must supply a loosely valid email for the input to be valid
`html`
When extending input validation with new validators use camelCase without 'data' when specifying the attribute name.
`javascript`
var validatior require('input-validation');
validator.add('greaterThanTen', function(value) {
return value !== undefined && parseInt(value,10) > 10;
})
The user must supply an int value greater than 10
`html``
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.