Skip to content

invalid pattern error #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
# cordova-plugin-decimal-keyboard

Cordova plugin to show decimal keyboard on iPhones
Cordova plugin to show decimal keyboard on iPhones forked from mrchandoo/cordova-plugin-decimal-keyboard

I was getting ng-pattern error(removed the pattern attribute to invoke the decimal keyboard), so just set the input to tel and add decimal=true to invoke the decimal keyboard

### Installing

```
cordova plugin add https://github.com/mrchandoo/cordova-plugin-decimal-keyboard.git
cordova plugin add https://github.com/msd117/cordova-plugin-decimal-keyboard.git

```
## Usage

```
<input type="text" pattern="[0-9]*" decimal="true">
<input type="tel" decimal="true">
```
Input type number will not work, try to use text with [0-9] pattern instead.
Input type number will not work, try to use tel .

<img src=https://github.com/mrchandoo/cordova-plugin-decimal-keyboard/blob/master/screenshots/Basic%20Usage.PNG width=25% height=25% /> <img src=https://github.com/mrchandoo/cordova-plugin-decimal-keyboard/blob/master/screenshots/Basic%20Usage%20Typed%20Content.PNG width=25% height=25% />


### Multiple decimals

```
<input type="text" pattern="[0-9]*" decimal="true" allow-multiple-decimals="true">
<input type="tel" decimal="true" allow-multiple-decimals="true">
```
<img src=https://github.com/mrchandoo/cordova-plugin-decimal-keyboard/blob/master/screenshots/Multiple%20Decimals.PNG width=25% height=25% />

### Different decimal character

```
<input type="text" pattern="[0-9]*" decimal="true" allow-multiple-decimals="false" decimal-char=",">
<input type="tel" decimal="true" allow-multiple-decimals="false" decimal-char=",">
```
If you want to localize decimal character, you can change using decimal-char attribute
<img src=https://github.com/mrchandoo/cordova-plugin-decimal-keyboard/blob/master/screenshots/Different%20Decimal%20Char.PNG width=25% height=25% />
Expand Down
2 changes: 1 addition & 1 deletion src/ios/CDVDecimalKeyboard.m
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ - (void)buttonPressCancel:(UIButton *)button{
- (void) isTextAndDecimal:(void (^)(BOOL isTextAndDecimal))completionHandler {
[self evaluateJavaScript:@"DecimalKeyboard.getActiveElementType();"
completionHandler:^(NSString * _Nullable response, NSError * _Nullable error) {
BOOL isText = [response isEqual:@"text"];
BOOL isText = [response isEqual:@"tel"];

if (isText) {
[self evaluateJavaScript:@"DecimalKeyboard.isDecimal();"
Expand Down