寫在model的 $validate array中
驗證方式
1) 自己寫function
2) 自己寫regex (cake使用preg_match)
3) 使用系統的rule
var $validate = array(
'nickname'=> array('rule'=>'checkNickname', 'required'=>false, 'message'=>'長度超過限制'),
'gander'=> array('rule'=>'/^1|0$/', 'required'=>false, 'on'=>'update'),
'height'=> array('rule'=>'numeric', 'required'=>false, 'allowEmpty'=>false, 'on'=>'update'),
);
function checkNickname($check) {
$value = array_values($check);
$value = $value[0];
$value = iconv('UTF-8', 'BIG5', $value);
if ($value && strlen($value)<=16)
return true;
else
return false;
}
Monday, March 22, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment