用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1029|回复: 2
收起左侧

[版本 3.x] 表单验证设置错误信息

[复制链接]
发表于 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() 之前
 楼主| 发表于 2015-11-3 09:38:43 | 显示全部楼层
一叶扁舟 发表于 2015-11-1 20:57
$this->form_validation->run() 之前

谢谢!!{:soso_e121:}

本版积分规则