Skip to content

Commit

Permalink
release v1.5.0
Browse files Browse the repository at this point in the history
The `digitOnly` directive will check the input `pattern` attribute if set, so that we can set the input only allow a certain format, especially for decimal numbers.

relates to #29
  • Loading branch information
changhuixu committed Apr 21, 2020
1 parent 4192a50 commit c5a6358
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Since **v1.1.0**, this directive accepts an attribute which indicates if the inp

Since **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.

Since **v1.5.0**, this directive will check the input `pattern` attribute if set. See an example below about an input only allows decimal numbers with precision of 2.

[![Build Status](https://img.shields.io/travis/changhuixu/ngx-digit-only/master.svg?label=Travis%20CI&style=flat-square)](https://travis-ci.org/changhuixu/ngx-digit-only)
[![npm](https://img.shields.io/npm/v/@uiowa/digit-only.svg?style=flat-square)](https://www.npmjs.com/package/@uiowa/digit-only)

Expand Down Expand Up @@ -80,4 +82,16 @@ export class YourModule { }
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"
/>
```
14 changes: 14 additions & 0 deletions projects/uiowa/digit-only/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Since **v1.1.0**, this directive accepts an attribute which indicates if the inp

Since **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.

Since **v1.5.0**, this directive will check the input `pattern` attribute if set. See an example below about an input only allows decimal numbers with precision of 2.

[![Build Status](https://img.shields.io/travis/changhuixu/ngx-digit-only/master.svg?label=Travis%20CI&style=flat-square)](https://travis-ci.org/changhuixu/ngx-digit-only)
[![npm](https://img.shields.io/npm/v/@uiowa/digit-only.svg?style=flat-square)](https://www.npmjs.com/package/@uiowa/digit-only)

Expand Down Expand Up @@ -80,4 +82,16 @@ export class YourModule { }
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"
/>
```
2 changes: 1 addition & 1 deletion projects/uiowa/digit-only/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@uiowa/digit-only",
"version": "1.4.1",
"version": "1.5.0",
"author": "Changhui Xu <[email protected]>",
"description": "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.",
"keywords": [
Expand Down
1 change: 0 additions & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ <h2>Try to type letters and numbers</h2>
digitOnly
decimal="true"
/>
/>

<p>
<a title="github" href="https://github.com/changhuixu/ngx-digit-only"
Expand Down

0 comments on commit c5a6358

Please sign in to comment.