numbers-only
v1.0.3
Published
Javascript event to only allow numbers in an input field
Downloads
7
Maintainers
Readme
Numbers Only
Overview
Javascript event handler to only allow numbers and a few special characters.
Works with text
and number
input types.
Allows the following characters:
tab
del
- left-arrow
- right-arrow
- 0 - 9 using standard keyboard
- 0 - 9 using a numberpad
Installation
Using npm
npm install numbers-only
Using yarn
yarn add numbers-only
Usage
It works best when you use numbersOnly
as the event handler for keydown
events.
import numbersOnly from 'numbers-only';
<input type="text" name="some-numeric-field" onkeydown="numbersOnly" />