Welcome Guest, Not a member yet? Register   Sign In
Form validation min_length not working
#1

[eluser]Gerep[/eluser]
Hi fellas,

I have this code:

Code:
$this->form_validation->set_rules('quadra_numero', 'Quadra nĂºmero', 'required|trim|numeric|xss_clean|min_length[3]|max_length[3]|callback_valida_quadra_setor');

The max_length[3] works but not the min_length[3].

I've checked the returned value with strlen($quadra_numero) and it returns me 2 characters but the validation seems to ignore it.

In my form I have the number 091, in my database it is a VARCHAR to keep the 0 that is
necessary.

If I post 0912 it will return the error for max_length but if I change it to 91 will pass the validation.

If I post 09 it will work, only with the 0(zero) removed it won't work.

Any ideas?

Thanks in advance for any help.
#2

[eluser]osci[/eluser]
I didn't check for min and max length for bug but there is a rule exact_length you could use.
#3

[eluser]Gerep[/eluser]
Thanks for the fast reply but it's not working, the problem is with the 0(zero)

I've found another post but it didn't work Post

I guess I'll have to check if the number have two characters, I'll add a 0(zero) and the beginning.

If there is a better way please help me =)

Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB