Welcome Guest, Not a member yet? Register   Sign In
Form validation MIN or MAX on posted array fields
#7

I am use callbacks in this case, but your way is most simple. I'll use your code to refact my project.

PHP Code:
$this->form_validation->set_rules('checkboxes[]''checks''required|callback_valid')->set_message('valid''Max 2 options');

public function 
valid()
 
   {
 
       $num count($this->input->post('checkboxes'));
 
       if ($num 2) {
 
           return false;
 
       } else {
 
           return true;
 
       }
 
   
Reply


Messages In This Thread
RE: Form validation MIN or MAX on posted array fields - by joao.coelho - 04-15-2017, 10:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB