You are here

function accordions_name_element_validate in Accordions 7

Form element validation handler that ensures accordion group names only contain alphanumeric characters, underscores or hyphens.

1 string reference to 'accordions_name_element_validate'
accordions_add_configure_accordion_form_element in ./accordions.module
Helper function for forms to use to add accordion item configuration.

File

./accordions.module, line 358

Code

function accordions_name_element_validate($element, &$form_state) {

  // Verify that the machine name contains no disallowed characters.
  $value = $element['#value'];
  if ($value !== '' && preg_match('@[^A-Za-z0-9_-]+@', $value)) {
    form_error($element, t('The accordion group name must contain only alphanumeric characters, hyphens or underscores.'));
  }
}