1.0.3 • Published 5 years ago

numbers-only v1.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Numbers Only

Build Status Coverage Status GitHub license NPM downloads GitHub issues

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" />