ZIP input component for virtual-dom
- Validates inputs using zippo
- Strips non-numeric characters
- Limits to 5 characters
- Triggers the large numeric keypad on mobile
Install
$ npm install --save zip-input
Usage
var ZipInput = var zipInput = { var vtree = ZipInput //=> use virtual-dom to patch vtree into real DOM}
API
ZipInput(data)
-> function
Create a new ZIP input observable state.
data
Type: object
The initial state of the input.
value
Type: string
The ZIP code.
ZipInput.validate(state)
-> boolean
Validate the current ZIP code value.
ZipInput.render(state, options) -> object
Render a ZIP input state to a vtree object. options
extend the defaults and are passed to virtual-hyperscript
License
MIT © Ben Drucker