number validator for entering decimals


(Maurizio Domba Cerin) #1

In some locales the separator for the decimal places is . (dot eg. 12.34), but some other locales uses , (comma eg. 12,34)

In CNumberValidator the line that checks if entered text is a number is:




if(!preg_match('/^\s*[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s*$/',"$value"))



so it checks only for . (dot), but we should consider all situations… maybe to use decimalFormat?


#2

+1


(Roman Solomatin) #3

Some kind of locale support would be greate, but maybe with a different name like CLocaleNumberValidator?