1.0.2 • Published 6 years ago

valli v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

Valli

Valli is an unobtrusive validator. It's designed on the basis of event-driven architecture with the help of HTML5.

Installation

yarn add valli
# or "npm i valli"

Usage

<form>
  <input type="email" required>
  <input type="text" pattern="^\w+$">
  <button>submit</button>
</form>
import { Valli } from 'Valli';

const form = document.querySelector('form');
const controls = Array.from(document.querySelectorAll('input'));
const button = document.querySelector('button');

const valli = new Valli({ form, controls });

form.addEventListener('valli', ev => {
  const { el, valid } = ev.detail;
  el.style.background = valid ? '' : '#fcc';
  button.disabled = !valli.valid;
}, false);

See also

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago