You are here

function _validate_hex_color in Shadowbox 6.2

Same name and namespace in other branches
  1. 5.2 shadowbox.module \_validate_hex_color()
  2. 5 shadowbox.module \_validate_hex_color()
  3. 6.4 shadowbox.module \_validate_hex_color()
  4. 6.3 shadowbox.module \_validate_hex_color()
  5. 7.4 shadowbox.admin.inc \_validate_hex_color()
  6. 7.3 shadowbox.admin.inc \_validate_hex_color()

Validate a hex color value.

Parameters

$input: The string to validate.

Return value

TRUE if $input is a valid hex color value (e.g. 000 or 000000)

1 call to _validate_hex_color()
shadowbox_global_settings_validate in ./shadowbox.module
Validate admin settings form inputs.

File

./shadowbox.module, line 1047
Shadowbox, a JavaScript media viewer application for displaying content in a modal dialogue.

Code

function _validate_hex_color($input, $long = FALSE) {
  if ($long == TRUE) {
    return preg_match('!^[a-f0-9]{6}$!i', $input);
  }
  else {
    return preg_match('!^[a-f0-9]{3}([a-f0-9]{3})?$!i', $input);
  }
}