Nurturing Palpable Magnificence

npm

Share private packages across your team with npm Orgs, now with simplified billing via the aws marketplace!Learn more »

@uiowa/digit-only

1.1.1 • Public • Published

Angular DigitOnly Directive

An Angular directive only allows [0-9] in the input box when typing, pasting or drag/dropping. This directive handles both Windows keyboard and Mac keyboard.

Since v1.1.0, this directive also accepts an attribute which indicates if the input number allows a decimal point.

Build Status npm

Medium Article

Demo

Installation

npm i -S @uiowa/digit-only

Usage

// in your Angular module
import { DigitOnlyModule } from '@uiowa/digit-only';
 
@NgModule({
  declarations: [
    ...
  ],
  imports: [
    BrowserModule,
    DigitOnlyModule
  ],
  ...
})
export class YourModule { }
// in your component.html
<input type="text" digitOnly>
 
// pull out the numeric keypad in mobile devices and tablets
<input type="text" name="zipcode" id="zipcode"
    placeholder="00000" maxlength="5"
    inputmode="numeric" pattern="[0-9]*" digitOnly>
 
// turn off browser autocomplete
<input ... autocomplete="off">
 
// allows decimal input
<input id="decimal-number" type="text" digitOnly decimal="true" placeholder="000">

install

npm i @uiowa/digit-only

Downloadsweekly downloads

1,421

version

1.1.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
Report a vulnerability