$rules = array( array('cardnum', '/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/', '身份证号格式不正确!'),);if (!$User->validate($rules)->create()) { $this->error($User->getError());}