angular-eha.only-digits

1.0.2 • Public • Published

angular-eha.only-digits

Build Status

Provides a Angular directive for input fields to ensure that only digits are accepted. Optionally converts the input to an integer.

Installation

Install with npm:

npm install --save angular-eha.only-digits

Or alternatively, with Bower:

bower install --save angular-eha.only-digits

Usage

Add eha.only-digits to your app's module dependencies:

angular.module('app', [
  'eha.only-digits'
]);

Use like this:

<input type="text" only-digits>
<input type="text" only-digits convert-to-number="true">

The input field has to be of type text, otherwise the browser will send undefined as value when there is invalid input and we cannot hook into ngModel.$parsers to remove unwanted chars.

Optionally convert-to-number="true" can be set to convert the the string input value to a number before its set on the model.

License

Apache 2.0, see LICENSE

Author

© 2015 Till Reitemeyer & Robin Mehner for eHealth Systems Africa

Dependencies (0)

    Dev Dependencies (17)

    Package Sidebar

    Install

    npm i angular-eha.only-digits

    Weekly Downloads

    2

    Version

    1.0.2

    License

    Apache-2.0

    Last publish

    Collaborators

    • adamthompson
    • rmehner