Welcome Guest, Not a member yet? Register   Sign In
have you ever tried form_error() ?
#1

[eluser]runrun[/eluser]
If you know how to use this please help me.

This is my form:
Code:
<form id="register_form" method="post">
    <table width="543" cellpadding="0" cellspacing="0" id="register_table">
        <tr>
            <td width="168" class="align_r"><label for="email"><abbr>*</abbr>Emai:</label></td>
            <td width="373">
                &lt;input type="text" name="email" id="email" value="&lt;?=$this-&gt;validation->email?&gt;" />
                <span>&lt;?=form_error('email')?&gt;</span>
            </td>
        </tr>
        <tr>
            <td class="align_r"><label for="password"><abbr>*</abbr>Password:</label></td>
            <td>
                &lt;input type="password" name="password" id="password" value="&lt;?=$this-&gt;validation->password?&gt;" />
                &lt;?=form_error('password')?&gt;
            </td>
        </tr>
        <tr>
            <td></td>
            <td>&lt;input type="submit" value="submit" /&gt;&lt;/td>
        </tr>
    </table>
&lt;form&gt;

this is controller:
Code:
$this->load->library('validation');
        
$rules['email'] = 'trim|required|valid_email';
$rules['password'] = 'trim|required|matches[password_confirm]|min_lenght[5]|md5';

$this->validation->set_rules($rules);

$fields['email'] = 'Email';
$fields['password'] = 'Password';

$this->validation->set_fields($fields);
$data['l']='';

if ($this->validation->run() == FALSE)
{
    $this->load->view('register_view',$data);
}
else
{
    $this->db->insert('user', $_POST);    
    redirect('register/register_success');
}

There is no error message when I submit empty form.
#2

[eluser]pistolPete[/eluser]
You are using the deprecated Validation library instead of the newer Form Validation library.
form_error() is used in the newer one.
#3

[eluser]runrun[/eluser]
I want to set multiple rules using array is it possible ?
#4

[eluser]TheFuzzy0ne[/eluser]
[url="http://ellislab.com/codeigniter/user-guide/libraries/form_validation.html#validationrulesasarray"]RTFUG[/url]. Smile
#5

[eluser]runrun[/eluser]
Thanks but I mean multiple rules.
#6

[eluser]pistolPete[/eluser]
There is no difference between using arrays and multiple calling set_rules().
The cascading rules example from the userguide using arrays would look like:
Code:
$config = array(
               array(
                     'field'   => 'username',
                     'label'   => 'Username',
                     'rules'   => 'required|min_length[5]|max_length[12]'
                  ),
               array(
                     'field'   => 'password',
                     'label'   => 'Password',
                     'rules'   => 'required|matches[passconf]'
                  ),
               array(
                     'field'   => 'passconf',
                     'label'   => 'Password Confirmation',
                     'rules'   => 'required'
                  ),  
               array(
                     'field'   => 'email',
                     'label'   => 'Email',
                     'rules'   => 'required|valid_email'
                  )
            );
#7

[eluser]runrun[/eluser]
Thanks, man.




Theme © iAndrew 2016 - Forum software by © MyBB