I have a textfield that user can enter only numbers.
How i can validate the field that when the number is float, it can have max 2 pre decimal and 2 decimal numbers?
I have a textfield that user can enter only numbers.
How i can validate the field that when the number is float, it can have max 2 pre decimal and 2 decimal numbers?
Not sure if I understood your question, here is numerical validator document.
http://www.yiiframework.com/doc/api/1.1/CNumberValidator
If it cannot solve your issue, you may look for extension for validation, then base on this code you can do a little change to create one by yourself.
For example:
try this
array('percent', 'numerical', 'allowEmpty' => true,
'integerOnly' => false, 'min' => 0, 'max' => 100),
Thank you all for your replies.
I use the one Maggie suggested and then with numberPattern option i use a regular expression to filter the format I want.
Thanks for your time and suggestions!