日期格式的验证
array('start_date',
'date',
'allowEmpty'=>true,
'format'=>'yyyy-MM-dd',
'message'=>'开始日格式不正确!',
'on'=>'select'),
array('end_date',
'date',
'allowEmpty'=>true,
'format'=>'yyyy-MM-dd',
'message'=>'开始日格式不正确!',
'on'=>'select'),
邮件地址的验证
array('email',
'match',
'allowEmpty'=>false,
'pattern'=>'/(\w[-._\w]*\w@\w[-._\w]*\w\.\w{2,3})/',
'message'=>'请输入正确的邮件地址!'
'on'=>'regist'),
public function afterValidate() {
parent::afterValidate();
if ($this->scenario == "regist") {
$validator = new CEmailValidator();
if (!$validator->validateValue($email)) {
$this->addError("email", "请输入正确的邮件地址!");
}
}
}
2698

被折叠的 条评论
为什么被折叠?



