我正在尝试为set_rule....is设置验证消息这是可能的吗?
我试过了
$this->form_validation->set_rules('payment_amount', 'Payment Amount', 'regex_match[/^\d{0,4}(\.\d{1,2})?$/]');
$this->form_validation->set_message('payment_amount', 'This is a test');我的信息并没有改变。
有什么想法吗?
发布于 2013-01-19 06:30:01
您可以通过为规则创建函数来设置自定义验证错误消息。
这段代码是未经测试的。
public function payment_amount($str)
{
if (preg_match('[/^\d{0,4}(\.\d{1,2})?$/]', $str)
{
$this->form_validation->set_message('payment_amount', 'The %s field has an error');
return FALSE;
}
else
{
return TRUE;
}
}我们CI的回调如下:
$this->form_validation->set_rules('payment_amount', 'Payment Amount', 'callback_payment_amount')https://stackoverflow.com/questions/14408658
复制相似问题