What is the best way and the solution to validate a string that must represents a price value with dot or comma and with maximum two decimal values?
RegExp
, java.text.DecimalFormat
or something else?
These values are accepted:
1
11
1,05
2,5
1.05
2.5
I see these solution but these are not exactly what I want:
valdating a 'price' in a jtextfield
I also try this RegExp /^(\\d+(?:[\\.\\,]\\d{2})?)$/
but it doesn't work.