Closed udayghulaxe closed 6 years ago
+1
Anyone with this issue... use this regex instead: ^(\d|-)?(\d|,).?\d$
Closing, it sounds like there's a workaround.
this '^(\d|-)?(\d|,).?\d$' not found to me
NB, this is talking about decimal fractions, not simply decimal (aka base 10).
Today I also ran into this issue and after further investigation into the paper-input's source code, which is a styled version of the iron-input, I saw this line:
Basically they're testing the Regex for every single character on the input's value and not the full one which is rather misleading since the property is called allowedPattern and not something along the lines of allowedCharacters. I'd suggest either one of the two following options:
Edited: I checked the documentation and it's very explicit how the allowedPattern actually works but I still think this component would benefit more from testing the entirety of the value. One can perfectly control the allowed characters by testing the whole string against the regex but it's impossible for one to control the whole input's value by testing each character individually.
Description
I am using allowed pattern in paper-input to restrict user to input maximum two decimal places. I am using
allowed-pattern
with RegEx^[0-9]+(\.[0-9]{1,2})?$
. The problem I have is that when I want to type a decimal number paper-input is not allowing me to type decimal point. I don't want to use "pattern" property and then show error message, I want to restrict user from inputting more than two decimal places.Expected outcome
When using regex with the
allowedPattern
property, I want to be able to input decimal points also.Actual outcome
I am not able to enter decimal point numbers.
Live Demo
http://plnkr.co/edit/qdcdDvIBLuuDVORb5wfF?p=preview
Steps to reproduce