You are here

function mcd_form_validate in Maintenance Countdown 7

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

Validation handler for time fields. All fields must be numeric

1 string reference to 'mcd_form_validate'
mcd_form_alter in ./mcd.module
Implements hook_form_alter().

File

./mcd.module, line 218
mcd.module

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;
    }
  }
}