You are here

function copyright_block_validate_start_year in Copyright Block module 6

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

Validates the start year.

1 string reference to 'copyright_block_validate_start_year'
copyright_block_block in ./copyright_block.module
Implementation of hook_block().

File

./copyright_block.module, line 70
Creates a dynamic customisable copyright message block.

Code

function copyright_block_validate_start_year($element, &$form_state) {
  $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.'));
  }
}