You are here

function eu_cookie_compliance_validate_hex in EU Cookie Compliance (GDPR Compliance) 7

Same name and namespace in other branches
  1. 8 eu_cookie_compliance.module \eu_cookie_compliance_validate_hex()
  2. 7.2 eu_cookie_compliance.admin.inc \eu_cookie_compliance_validate_hex()

Validate field for a HEX value if a value is set.

Parameters

array $element: Form element.

array $form_state: Form state array.

1 string reference to 'eu_cookie_compliance_validate_hex'
eu_cookie_compliance_admin_form in ./eu_cookie_compliance.admin.inc
Provides form for cookie control banner.

File

./eu_cookie_compliance.admin.inc, line 1049
This file provides administration form for the module.

Code

function eu_cookie_compliance_validate_hex(array $element, array &$form_state) {
  if (!empty($element['#value']) && !preg_match('/^[0-9a-fA-F]{3,6}$/', $element['#value'])) {
    form_error($element, t('%name must be a HEX value (without leading #) or empty.', array(
      '%name' => $element['#title'],
    )));
  }
}