function date_validate

date_validate($element)

Validates the date type to prevent invalid dates (e.g., February 30, 2006).

Related topics

File

includes/form.inc, line 3136
Functions for form and batch generation and processing.

Code

function date_validate($element) {
  if (!checkdate($element['#value']['month'], $element['#value']['day'], $element['#value']['year'])) {
    form_error($element, t('The specified date is invalid.'));
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!form.inc/function/date_validate/7.x