You are here

function _regex_field_validation_regex_validate in RegEx Field Validation 7

Validates field value against regular expression.

1 string reference to '_regex_field_validation_regex_validate'
regex_field_validation_form_alter in ./regex_field_validation.module
Implements hook_form_alter().

File

./regex_field_validation.module, line 111
RegEx Field Validation module file.

Code

function _regex_field_validation_regex_validate($element, $form_state) {
  if (!preg_match_all($form_state['field'][$element['und']['#field_name']]['und']['instance']['settings']['regex_field_validation_widget']['regex'], $form_state['values'][$element['und']['#field_name']]['und'][0]['value'])) {
    form_set_error($element['und']['#field_name'], t($form_state['field'][$element['und']['#field_name']]['und']['instance']['settings']['regex_field_validation_widget']['error_message']));
  }
}