on
코드이그나이터) 폼 검증
코드이그나이터) 폼 검증
참고 사이트: http://www.ciboard.co.kr/user_guide/kr/libraries/form_validation.html
$this->form_validation->set_rules(필드이름,알기쉬운이름,검사규칙);
*검사규칙:
1.값 반드시 존재-required
2.패스워드 확인-required|matches[password]
3.길이제한-required|min_length[5]|max_length[12]
4.유효한이메일,유일값-required|vaild_email|is_unique[users.email]
5.숫자인지,길이제한-numeric|max_length[3]|min_length[2]|required
6.함수 사용
$this->form_validation->set_rules('username','Kate', array('required', array($this->user_model, 'valid_username'));
7.콜백함수(db필요시에 controller에 함수추가)-callback_callFn[$str]
public function callFn($str){
if($str=='test'){
$this->form_validation->set_message('username_check', The {field} field can be the word "test"');
return false;
}else{
return true;
}
}
from http://develyuper.tistory.com/16 by ccl(A) rewrite - 2020-04-20 23:01:27