numbers-only
v1.0.3
Published
Javascript event to only allow numbers in an input field
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:
tabdel- left-arrow
- right-arrow
- 0 - 9 using standard keyboard
- 0 - 9 using a numberpad
Installation
Using npm
npm install numbers-onlyUsing yarn
yarn add numbers-onlyUsage
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" />