All Projects → changhuixu → Ngx Digit Only

changhuixu / Ngx Digit Only

Licence: mit
An Angular directive to only allow [0-9] in the input box when typing, pasting or drag/dropping.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Ngx Digit Only

angular2-stretchy
angular2-stretchy is an Angular2 directive that automatically adjusts input width to fit content.
Stars: ✭ 12 (-88.79%)
Mutual labels:  input, directive
angular-datetime-inputs
📅 Angular directives for datetime inputs
Stars: ✭ 20 (-81.31%)
Mutual labels:  input, directive
Alertjs
Dialog Builder allows you to create fully customisable dialogs and popups in Dynamics 365.
Stars: ✭ 80 (-25.23%)
Mutual labels:  input
Angular Es6
Angular ES6 utility library. Write directives, controllers and services as ES6 classes.
Stars: ✭ 103 (-3.74%)
Mutual labels:  directive
Evscript
A tiny sandboxed Dyon scripting environment for evdev input devices that lets you do e.g. xcape in Wayland
Stars: ✭ 91 (-14.95%)
Mutual labels:  input
React Tagsinput
Highly customizable React component for inputing tags.
Stars: ✭ 1,241 (+1059.81%)
Mutual labels:  input
Suohai
Audio input/output source lock/switcher for macOS.
Stars: ✭ 100 (-6.54%)
Mutual labels:  input
Agm Direction
This is the directive for @agm/core (not official)
Stars: ✭ 77 (-28.04%)
Mutual labels:  directive
Tagify
🔖 lightweight, efficient Tags input component in Vanilla JS / React / Angular / Vue
Stars: ✭ 2,305 (+2054.21%)
Mutual labels:  input
V Click Outside X
Vue V2 directive to react on clicks outside an element.
Stars: ✭ 91 (-14.95%)
Mutual labels:  directive
React Input Enhancements
Set of enhancements for input control
Stars: ✭ 1,375 (+1185.05%)
Mutual labels:  input
Neatinput
A .NET standard project which aims to make keyboard and mouse input monitoring easy on Windows and eventually Linux.
Stars: ✭ 89 (-16.82%)
Mutual labels:  input
Verlyrangeslider
Range sliders with some verlet physics magic.
Stars: ✭ 84 (-21.5%)
Mutual labels:  input
Customalertviewdialogue
Custom AlertView Dialogue is the world's most advanced alert view library. Custom AlertView Dialogue includes simple message popups, confirmation alerts, selector popups, action sheet bottom menus, and input/feedback contact forms.
Stars: ✭ 100 (-6.54%)
Mutual labels:  input
Gilrs
Game Input Library for Rust - Mirror of https://gitlab.com/gilrs-project/gilrs
Stars: ✭ 81 (-24.3%)
Mutual labels:  input
React Native Segmented Text Input
A wickedly customizable <TextInput /> for React Native. Useful for tags, spellchecking, whatever.
Stars: ✭ 104 (-2.8%)
Mutual labels:  input
React Categorized Tag Input
React.js component for making tag autocompletion inputs with categorized results.
Stars: ✭ 78 (-27.1%)
Mutual labels:  input
Core Components
Accessible and lightweight Javascript components
Stars: ✭ 85 (-20.56%)
Mutual labels:  input
Swipe
A plugin for Unreal Engine 4 that exposes swipes on mobile devices as events in blueprint.
Stars: ✭ 91 (-14.95%)
Mutual labels:  input
Vue Places
Places component is based on places.js for Vue 2.x. Turn any <input> into an address autocomplete.
Stars: ✭ 106 (-0.93%)
Mutual labels:  input

Angular DigitOnly Directive and Mask Directive

Build Status npm

Demo

Medium Article: Digit Only Directive in Angular

  • [x] input 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. This directive works with input type="text", not input type="number".

  • [x] input mask directive

    This directive checks the input pattern attribute if set.

CHANGELOG

  • v2.2.2: fix an issue (#28) to prevent dead keys in the digitOnly directive.

  • v2.2.1: digitOnly directive now dispatches an input event when paste in Firefox.

  • v2.2.0: fix an issue (#35): for better international support, both mask and digitOnly directives now also check the code attribute in KeyboardEvent.

  • v2.1.0(v1.9.0): fix an issue (#39) when typing decimal numbers for the digitOnly directive

  • v2.0.0: add tslib v2.0 in the dependency, which is required by TypeScript 3.9 (as of Angular 10).

  • v1.8.0: fix an issue (#38) when pasting in IE and Edge for the digitOnly directive

  • v1.7.0: the digitOnly directive allows model binding to min, max, and pattern properties.

    • See demo page for examples.
  • v1.6.0: the mask directive is added to this library.

    • See an example below about an input allows ##-####.
  • v1.5.0: this directive checks the input pattern attribute if set.

    • See an example below about an input only allows decimal numbers with precision of 2.
  • v1.3.0: this directive accepts an attribute for the separator for decimal numbers.

    • By default, the separator is a .. You can set it to comma when needed.
  • v1.1.0: this directive accepts an attribute which indicates if the input number allows a decimal point.


Installation

npm i @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"
/>

// allows to set decimal separator
<label for="digit-only-decimal-comma">
  Digit Only input box that allows a <i>decimal point</i> using
  <strong>a comma as the separator</strong>
</label>
<input
  id="digit-only-decimal-comma"
  type="text"
  digitOnly
  decimal="true"
  decimalSeparator=","
  placeholder="0,00"
  pattern="[0-9]+([,][0-9]+)?"
/>

// Digit Only input only allows two decimal places
<input
  id="currency"
  type="text"
  name="currency"
  inputmode="numeric"
  pattern="^\d+(\.\d{1,2})?$"
  placeholder="0.00"
  digitOnly
  decimal="true"
/>

mask directive usage

// input masked with pattern attribute: <code>##-####</code>
<input
  id="org-dept"
  type="text"
  pattern="^(\d{0,2}|\d{2}-\d{0,4})$"
  name="org-dept"
  title="org-dept"
  placeholder="00-0000"
  mask
/>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].