Welcome Guest, Not a member yet? Register   Sign In
Don't display validation error message
#1

[eluser]iniweb[/eluser]
This code:

Code:
$this->load->model('UserModel');

$rules['login']   = "trim|required|max_length[35]|xss_clean";
$rules['pwd']     = "trim|required|min_length[5]|matches[repwd]|md5";
$rules['repwd']   = "trim|required";
$rules['email']   = "trim|required|valid_email";
$rules['captcha'] = "required";

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

$this->validation->set_error_delimiters('<div class="error">', '</div>');
print_r($this->validation->error_string);
$this->validation->error_string;

Me enter password 4 letter, but:

Quote:[error_string] =>
[_error_array] => Array
(
)

[_error_messages] => Array
(
)
#2

[eluser]xwero[/eluser]
You first have to do $this->validation->run() before you can determine if there are error messages or not.

About the delimiter setting. That wraps around each error message so it's better to use a p tag if you want it displayed on another line or span if you want it inline. If you keep the error strings grouped you can do this in your view
Code:
<div id="errormsg">&lt;?php echo $this->validation->error_string; ?&gt;</div>
then in your css you can cascade from that id
Code:
#errormsg p {color:red;}
instead of having html looking like this
Code:
<p class="error">...</p>
<p class="error">...</p>
<p class="error">...</p>
<p class="error">...</p>
#3

[eluser]iniweb[/eluser]
Big thx's, and how display error if captcha not correct?




Theme © iAndrew 2016 - Forum software by © MyBB