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

[eluser]ameur[/eluser]
Hello,
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:
Code:
$this->load->library('form_validation');
                
                $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
#2

[eluser]xwero[/eluser]
You have to use placeholders to show the parameter, 3. The messages are formatted using sprintf so
Code:
$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
Code:
$this->form_validation->set_error_delimiters('<span class="single_error">&raquo; ', '</span>');
#3

[eluser]ameur[/eluser]
thank you, i try it but it did'nt work :-S
#4

[eluser]xwero[/eluser]
somehow the percent sign was removed so the place holder is %2$d, or maybe i just forgot to type it Smile
#5

[eluser]ameur[/eluser]
yes it works :lol:
thank you very well ;-)




Theme © iAndrew 2016 - Forum software by © MyBB