You are here

function birthdays_date_validate in Birthdays 6

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

Validate the birthday field.

1 string reference to 'birthdays_date_validate'
birthdays_form_alter in ./birthdays.module
Implementation of hook_form_alter().

File

./birthdays.module, line 806
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) {
  if (empty($element['#value'])) {
    return;
  }
  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.'));
  }
}