I am using the following regex to validate decimal numbers with dot .
.
/^[0-9]*\\.?[0-9]*$/
It works fine for all the cases except
Simply add one or more quantificator:
^[0-9]+(\.[0-9]+)?$
You can use this regex:
/^\d+(\.\d+)?$/
It will match whole number: 12, 1222
12
1222
If there is a decimal point, then there must be at least 1 digit before and after the decimal point: 1.1, 34.2
1.1
34.2
These cases are not allowed: .43, 23.
.43
23.