function _clientside_validation_set_required in Clientside Validation 6
Same name and namespace in other branches
- 7 clientside_validation.module \_clientside_validation_set_required()
Set validation rule for required fields.
3 calls to _clientside_validation_set_required()
- clientside_validation_cck in clientside_validation_form/
clientside_validation_form.module - clientside_validation_regular in clientside_validation_form/
clientside_validation_form.module - clientside_validation_webform_after_build_recurse in clientside_validation_webform/
clientside_validation_webform.module
File
- ./
clientside_validation.module, line 351 - Add client side validation to a webform.
Code
function _clientside_validation_set_required($name, $title, $required, &$js_rules, $message = '') {
$title = variable_get('clientside_validation_prefix', '') . $title . variable_get('clientside_validation_suffix', '');
if ($required) {
$js_rules[$name]['required'] = TRUE;
if (empty($message)) {
$variables = array(
'message' => '!title field is required.',
'placeholders' => array(
'!title' => $title,
),
'error_type' => 'required',
'element_name' => $name,
);
}
else {
$variables = array(
'message' => $message,
'error_type' => 'required',
'element_name' => $name,
);
}
$js_rules[$name]['messages']['required'] = theme('clientside_error', $variables);
}
}