Welcome Guest, Not a member yet? Register   Sign In
Display min_length

Please i want to display the value of min_length in my costum message because i've use it in two times (field username and field password)
this is my code:
                $this->form_validation->set_rules('username', 'Identifiant', 'trim|required|min_length[3]|alpha_numeric|xss_clean|callback__valid_username');
                $this->form_validation->set_rules('pwd', 'Mot de passe', 'trim|required|min_length[5]|md5');
                $this->form_validation->set_rules('email', 'Email', 'trim|valid_email');
                $this->form_validation->set_message('required', '» champ obligatoire');
                $this->form_validation->set_message('min_length', '» ce champ doit contenir au moins /*something missing here!!!*/ caracteres');
                $this->form_validation->set_message('_valid_username', '» cet identifiant est déja utilise');
                $this->form_validation->set_message('valid_email', '» email invalide');
                $this->form_validation->set_error_delimiters('<span class="single_error">', '</span>');
thank you Smile

You have to use placeholders to show the parameter, 3. The messages are formatted using sprintf so
$this->form_validation->set_message('min_length', '&raquo; ce champ doit contenir au moins %2$d caracteres');

A tip if your site is in French work with language files to set your messages instead of adding them to your code. And why not do
$this->form_validation->set_error_delimiters('<span class="single_error">&raquo; ', '</span>');

thank you, i try it but it did'nt work :-S

somehow the percent sign was removed so the place holder is %2$d, or maybe i just forgot to type it Smile

yes it works :lol:
thank you very well ;-)

Theme © iAndrew 2016 - Forum software by © MyBB