CodeIgniter Forums
Getting same set_message error for both the fields - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Getting same set_message error for both the fields (/showthread.php?tid=19877)



Getting same set_message error for both the fields - El Forum - 06-21-2009

[eluser]quest13[/eluser]
I am getting a error message as "* Password is required" for both field. I am not getting
"* Username is required'" for blank user name.

This is how I put the validation code in my controller
$this->form_validation->set_rules('username','Username','trim|required|min_length[5]|max_length[12]|xss_clean');
$this->form_validation->set_rules('password','Password','trim|required|');
$this->form_validation->set_message('required', '* Username is required');
$this->form_validation->set_message('required', '* Password is required');

if ($this->form_validation->run() == FALSE)
{
$this->template->load('/admin/login_template', '/admin/adminlogin_view', $data,'' );
//$this->template->load('/admin/template', '/admin/adminlogin_view', $data,'' );
}
else
{...
...

}
}


Getting same set_message error for both the fields - El Forum - 06-21-2009

[eluser]Thorpe Obazee[/eluser]
I believe set_message() was created for 1:1 purposes. One rule, one message. You are overwriting the former with the latter.

Just use set_delimiters() to add the additional asterisks.