You are here

function copyright_block_validate_start_year in Copyright Block module 7.2

Same name and namespace in other branches
  1. 6 copyright_block.module \copyright_block_validate_start_year()

Validate the start year.

1 string reference to 'copyright_block_validate_start_year'
copyright_block_block_configure in ./copyright_block.module
Implements hook_block_configure().

File

./copyright_block.module, line 106
Creates a dynamic copyright information block.

Code

function copyright_block_validate_start_year($element, &$form_state, $form) {
  $value = $element['#value'];
  $current_year = date('Y');
  if (!is_numeric($value)) {
    form_error($element, t('The start year must be numeric.'));
  }
  elseif (drupal_strlen($value) < 4) {
    form_error($element, t('The start year is too short.'));
  }
  elseif (drupal_strlen($value) > 4) {
    form_error($element, t('The start year is too long.'));
  }
  elseif ($value > $current_year) {
    form_error($element, t('The start year cannot be in the future.'));
  }
}