Leedaima 发表于 2015-10-30 16:25:54

表单验证设置错误信息

控制器:
<?php

class Form extends CI_Controller {

function index()
{
$this->load->helper(array('form', 'url'));

$this->load->library('form_validation');

$this->form_validation->set_rules('username', 'Username', 'callback_username_check');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');

if ($this->form_validation->run() == FALSE)
{
   $this->load->view('myform');
}
这是手册里的例子。
我先问的是 :$this->form_validation->set_message('rule', 'Error Message'); 这个函数该在什么的方使用呢?

一叶扁舟 发表于 2015-11-1 20:57:56

$this->form_validation->run() 之前

Leedaima 发表于 2015-11-3 09:38:43

一叶扁舟 发表于 2015-11-1 20:57
$this->form_validation->run() 之前

谢谢!!{:soso_e121:}
页: [1]
查看完整版本: 表单验证设置错误信息