[eluser]Nis Sarup[/eluser]
Here is the callback:
Code:
function _validate_birthday()
{
// Validates the birthdate from the user input.
$day = (int)$this->input->post('birthday');
$month = (int)$this->input->post('birthday_month');
$year = (int)$this->input->post('birthday_year');
if (0 > $day || $day > 32) {
$this->validation->set_message('validate_birthday', 'Invalid day in birthdate.');
return false;
}
if (0 > $month || $month > 13) {
$this->validation->set_message('validate_birthday', 'Invalid month in birthdate.');
return false;
}
if (0 > $day || $day > (int)date('Y')) {
$this->validation->set_message('validate_birthday', 'Invalid year in birthdate.');
return false;
}
$birthday = mktime(0, 0, 0, $month, $day, $year);
if ($birthday > strtotime('-18 years')) {
$this->validation->set_message('validate_birthday', 'You must be 18 years old to sign up.');
return false;
}
return $birthday;
}
It looks at the 3 inputs for the birthday, makes the timestamp and returns it if everything is allright.