Welcome Guest, Not a member yet? Register   Sign In
ensure user is 18 years of age - date valdation.
#6

[eluser]Andy78[/eluser]
[quote author="noctrum" date="1288808732"]You're mixing validation and form_validation. validation is deprecated, you should only be using form_validation[/quote]

Thanks for that! Sometimes you just cant see the wood for the trees, It just takes another set of eyes to the problem. I just somehow missed the form_ in front of validation.

This code now seems to be working well:

Code:
function valid_date()
    {
         $day     = $this->input->post('day');
         $month   = $this->input->post('month');
         $year    = $this->input->post('year');
          
         $birthday = mktime(0, 0, 0, $month, $day, $year);
          
        
        if (!checkdate($month,  $day, $year))
        {
            $this->form_validation->set_message('valid_date', 'The %s field is invalid.');
            return FALSE;
         }
        
        if ($birthday > strtotime('-18 years')) {
                $this->form_validation->set_message('valid_date', 'You must be 18 years old to sign up.');
                return false;
          }
            
            
          return TRUE;
    }

However should I be calling my callback valid_date() on each of the returned date values or is the last enough like so
Code:
$this->form_validation->set_rules('day', 'Day', 'trim|required');
        $this->form_validation->set_rules('month','month', 'trim|required');
        $this->form_validation->set_rules('year','year', 'trim|required|callback_valid_date');



Just want to ensure that this validation is in fact strong enough.


Messages In This Thread
ensure user is 18 years of age - date valdation. - by El Forum - 11-01-2010, 09:44 PM
ensure user is 18 years of age - date valdation. - by El Forum - 11-02-2010, 11:00 AM
ensure user is 18 years of age - date valdation. - by El Forum - 11-02-2010, 10:04 PM
ensure user is 18 years of age - date valdation. - by El Forum - 11-03-2010, 07:25 AM
ensure user is 18 years of age - date valdation. - by El Forum - 11-03-2010, 10:43 AM
ensure user is 18 years of age - date valdation. - by El Forum - 11-03-2010, 12:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB