Yii Framework Forum: number validator for entering decimals - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

number validator for entering decimals CNumberValidator does not consider locale number format Rate Topic: -----

#1 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,353
  • Joined: 12-October 09
  • Location:Croatia

Posted 19 February 2010 - 04:16 AM

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?
Find more about me.... btw. Do you know your WAN IP?
0

#2 User is offline   yiim 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 49
  • Joined: 28-June 12
  • Location:Germany

Posted 25 July 2012 - 09:28 AM

+1
0

#3 User is offline   Roman Solomatin 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 182
  • Joined: 21-October 10
  • Location:Tallinn, Estonia

Posted 01 September 2012 - 10:04 PM

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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users