You are here

function birthdays_date_validate in Birthdays 5

Same name and namespace in other branches
  1. 6 birthdays.module \birthdays_date_validate()

Validate the birthday field.

File

./birthdays.module, line 1171
The Birthdays module allows users to add their birthday to their profile. It lists birthdays on a seperate page and in different blocks. Users can receive an e-mail on their birthday automatically, and the administrator can receive daily reminders of…

Code

function birthdays_date_validate($element) {
  extract($element['#value']);
  if (empty($month) || empty($year) || empty($day)) {
    if ($element['#required']) {
      form_error($element, t('!name field is required.', array(
        '!name' => $element['#title'],
      )));
    }
    elseif (!(empty($month) && empty($year) && empty($day))) {
      form_error($element, t('The specified date is invalid.'));
    }
  }
  elseif (!checkdate($month, $day, $year)) {
    form_error($element, t('The specified date is invalid.'));
  }
}