function _clientside_validation_set_regex in Clientside Validation 6
Same name and namespace in other branches
- 7 clientside_validation.module \_clientside_validation_set_regex()
Set validation rule for fields with regex validation from webform_validation
2 calls to _clientside_validation_set_regex()
- clientside_validation_webform_add_webform_validation in clientside_validation_webform/
clientside_validation_webform.module - Support webform_validation
- hook_clientside_validation_rule_alter in ./
clientside_validation.api.php - Some modules allow users to define extra validation rules defined in a hook. (e.g hook_webform_validation_validators()). To support these custom rules, clientside validation has its own hook, hook_clientside_validation_rule_alter. We had to use an…
File
- ./
clientside_validation.module, line 862 - Add client side validation to a webform.
Code
function _clientside_validation_set_regex($name, $title, &$js_rules, $expression, $message = '', $modifiers = "", $type = 'regex') {
$title = variable_get('clientside_validation_prefix', '') . $title . variable_get('clientside_validation_suffix', '');
if (empty($message)) {
$variables = array(
'message' => '!title field does not match the required pattern.',
'placeholders' => array(
'!title' => $title,
),
'error_type' => $type,
'element_name' => $name,
);
}
else {
$variables = array(
'message' => $message,
'error_type' => $type,
'element_name' => $name,
);
}
$message = theme('clientside_error', $variables);
$js_rules[$name]['regexMatch'] = array(
$expression,
);
if (!empty($modifiers)) {
$js_rules[$name]['regexMatch'][] = $modifiers;
}
$js_rules[$name]['messages']['regexMatch'] = $message;
}