3

我正在使用 zend 框架和带有验证器的 zend 表单,DIGIT如下所示:

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

但它不传递负数并给出此错误:

'-4000' contains not only digit characters

我现在能做什么?

4

1 回答 1

6

来自 Zend Framework文档

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
于 2013-06-06T05:34:25.247 回答