You are here

function clientside_validation_add_xregexp in Clientside Validation 7.2

Same name and namespace in other branches
  1. 6 clientside_validation.module \clientside_validation_add_xregexp()
  2. 7 clientside_validation.module \clientside_validation_add_xregexp()
1 call to clientside_validation_add_xregexp()
_clientside_validation_add_general_settings in ./clientside_validation.module

File

./clientside_validation.module, line 557
Add client side validation to forms.

Code

function clientside_validation_add_xregexp(&$form) {
  $variant = variable_get('clientside_validation_xregxp_variant', '');
  $lib = libraries_detect('xregexp');
  if (empty($variant)) {
    $form['#attached']['libraries_load'][] = array(
      'xregexp',
    );
    return !isset($lib['error']) || !$lib['error'] ? 1 : 0;
  }
  else {
    $form['#attached']['libraries_load'][] = array(
      'xregexp',
      $variant,
    );
    return isset($lib['variants'][$variant]) && (!isset($lib['variants'][$variant]['error']) || !$lib['variants'][$variant]['error']) ? 1 : 0;
  }
}