You are here

function _mobile_switch_block_cookie_expire_validate in Mobile Switch Block 7.2

Same name and namespace in other branches
  1. 6 mobile_switch_block.module \_mobile_switch_block_cookie_expire_validate()
  2. 7 mobile_switch_block.module \_mobile_switch_block_cookie_expire_validate()

Render API callback: Validates the cookie expire value.

Ensures that only numbers and no white spaces has been entered.

This function is assigned as an #element_validate callback in mobile_switch_block_form_mobile_switch_advanced_settings_form_alter().

1 string reference to '_mobile_switch_block_cookie_expire_validate'
mobile_switch_block_form_mobile_switch_advanced_settings_form_alter in ./mobile_switch_block.module
Implements hook_form_FORM_ID_alter().

File

./mobile_switch_block.module, line 189
Extends the Mobile Switch module with an theme switch block.

Code

function _mobile_switch_block_cookie_expire_validate($element, &$form_state) {
  if (preg_match("/[^0-9]/", $element['#value'])) {
    form_error($element, t('%title: Only numbers and no white spaces are possible.', array(
      '%title' => t($element['#title']),
    )));
  }
}