function styleguide_palette_swatch_validate_hex in Style Guide 7
Form element validation handler for hex elements.
1 string reference to 'styleguide_palette_swatch_validate_hex'
- styleguide_palette_form in styleguide_palette/
styleguide_palette.admin.inc - Form constructor for the style guide swatch form.
File
- styleguide_palette/
styleguide_palette.admin.inc, line 129 - Administrative page callbacks for the Style Guide Swatch module.
Code
function styleguide_palette_swatch_validate_hex($element, &$form_state) {
$value = strtolower($element['#value']);
if ($value !== '' && !preg_match('/^#([a-f0-9]{3}){1,2}$/iD', $value)) {
form_error($element, t('%name must be a valid hexadecimal CSS color value.', array(
'%name' => $element['#title'],
)));
}
}