function _clientside_validation_set_number_decimal in Clientside Validation 6
Same name and namespace in other branches
- 7 clientside_validation.module \_clientside_validation_set_number_decimal()
Set validation rule for decimal fields.
2 calls to _clientside_validation_set_number_decimal()
- clientside_validation_cck in clientside_validation_form/
clientside_validation_form.module - _clientside_validation_set_fapi_validation in clientside_validation_fapi/
clientside_validation_fapi.module - Set fapi validation.
File
- ./
clientside_validation.module, line 392 - Add client side validation to a webform.
Code
function _clientside_validation_set_number_decimal($name, $title, $decimalpoint, &$js_rules, $message = '') {
if (empty($decimalpoint)) {
$decimalpoint = '.';
}
$title = variable_get('clientside_validation_prefix', '') . $title . variable_get('clientside_validation_suffix', '');
if ($decimalpoint == '.') {
$js_rules[$name]['number'] = TRUE;
$variables = array(
'message' => empty($message) ? '!title field accepts only numbers (use a \'.\' as decimal point).' : $message,
'placeholders' => empty($message) ? array(
'!title' => $title,
) : array(),
'error_type' => 'number',
'element_name' => $name,
);
$js_rules[$name]['messages']['number'] = theme('clientside_error', $variables);
}
else {
$js_rules[$name]['numberDE'] = TRUE;
$variables = array(
'message' => empty($message) ? '!title field accepts only numbers (use a \',\' as decimal point).' : $message,
'placeholers' => empty($message) ? array(
'!title' => $title,
) : array(),
'error_type' => 'number',
'element_name' => $name,
);
$js_rules[$name]['messages']['numberDE'] = theme('clientside_error', $variables);
}
}