如何使用yii在textfield中传递格式编号的错误验证?

时间:2014-01-03 04:21:17

标签: yii

我在文本字段中使用扩展moneymaskking但是在保存数据时我得到验证错误,像这样的错误“jum Byr Pokok必须是一个数字”,textfiels中的值是5.000.000,以保存数据并通过验证在文本字段中格式化数字钱?

Tks&的问候,

1 个答案:

答案 0 :(得分:0)

可以非常简单地添加正则表达式

就像模型文件中那样

public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
    array('your_price_field', 'match','pattern'=>'/^\d{0,8}(\.\d{1,4})?$/', 'message'=>'{attribute} can only contain Price.'),
);
    }
相关问题