I'm using: .js/index.html to mask inputs.
I'm looking at "patterns" option and am having trouble writing the regex expression for 1 or 2 digits with an optional decimal place.
Good inputs:
2.5
12.5
.5
1
Bad inputs:
.25
123.5
1.55
Thank you for any help!
I'm using: http://firstopinion.github.io/formatter.js/index.html to mask inputs.
I'm looking at "patterns" option and am having trouble writing the regex expression for 1 or 2 digits with an optional decimal place.
Good inputs:
2.5
12.5
.5
1
Bad inputs:
.25
123.5
1.55
Thank you for any help!
Share Improve this question asked May 16, 2014 at 22:26 user1786605user1786605 631 gold badge1 silver badge7 bronze badges1 Answer
Reset to default 17^\d{0,2}(?:\.\d)?$
\d{0,2}
= 0-2 digits\.\d
= decimal point followed by 1 digit(?: ... )?
= optional group^
and$
anchor it to beginning and end
DEMO