Abadis
Abadis

Reputation: 2821

Zend Validator for digits with negative mark

Iam using zend framework and zend form with validator DIGIT like this :

    $ZV_Digit=new Zend_Validate_Digits();
    $credit = new Zend_Form_Element_Text('credit');
    $credit->setLabel('current credit');
    $credit->setValidators(array($ZV_Digit));

But it does not pass negative numbers and gives this error :

'-4000' contains not only digit characters

What can I do now?

Upvotes: 3

Views: 1264

Answers (1)

Awais Qarni
Awais Qarni

Reputation: 18006

From Zend Framework documentation

Note: Validating numbers
When you want to validate numbers or numeric values, 
be aware that this validator only validates digits.
This means that any other sign like a thousand separator
or a comma will not pass this validator.
In this case you should use Zend_Validate_Int or Zend_Validate_Float

Upvotes: 6

Related Questions