【问题标题】:Zend Validator for digits with negative markZend Validator 用于带负号的数字
【发布时间】:2013-06-06 05:27:39
【问题描述】:

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

    $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

我现在能做什么?

【问题讨论】:

    标签: php validation zend-framework


    【解决方案1】:

    来自 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-21
      相关资源
      最近更新 更多