Welcome Guest, Not a member yet? Register   Sign In
How to validate dropdown/selct data
#3

[eluser]Sumon[/eluser]
using a custom validation may be a good choice. by example in form_validation.php add a validation rule
Code:
$this->form_validation->set_rules('sel_sex', 'sex', 'required|callback_check_sex');
and the function check_sex code
Code:
function check_sex()
{
   $valid_selections = array('m','M','f','F');
   $x = $_POST['sel_sex'];
   if(in_array($x , $valid_selections))
   {
     return true;
   }
   else
   {
     $this->form_validation->set_message('check_sex', 'invalid choice');
     return FALSE;
   }
}


Messages In This Thread
How to validate dropdown/selct data - by El Forum - 12-24-2008, 12:47 PM
How to validate dropdown/selct data - by El Forum - 12-24-2008, 10:18 PM
How to validate dropdown/selct data - by El Forum - 12-25-2008, 12:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB