You are here

function mcd_form_validate in Maintenance Countdown 6

Same name and namespace in other branches
  1. 7 mcd.module \mcd_form_validate()

Validation handler for time fields.

All fields must be numeric. So if nothing given fill zero.

1 string reference to 'mcd_form_validate'
mcd_form_system_site_maintenance_settings_alter in ./mcd.module
Implements hook_form_FORM_ID_alter().

File

./mcd.module, line 114
This module provides the maintenance page with nice countdown timer. So now you may set time for your maintenance work and your visitors will see when time is up.

Code

function mcd_form_validate($form, &$form_state) {
  foreach (array(
    'mcd_months',
    'mcd_days',
    'mcd_hours',
    'mcd_minutes',
    'mcd_seconds',
  ) as $field) {

    // check if fields are numeric
    if (!empty($form_state['values'][$field])) {
      if (!is_numeric($form_state['values'][$field])) {
        form_set_error($field, t('Time must be entered as number, check field(s).'));
      }
    }
    else {
      $form_state['values'][$field] = 0;
    }
  }
}