[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.