You are here

function dfp_breakpoint_form_validate in Doubleclick for Publishers (DFP) 7.2

Same name and namespace in other branches
  1. 7 dfp.admin.inc \dfp_breakpoint_form_validate()

Validation function used by an individual breakpoint in the breakpoints form.

1 string reference to 'dfp_breakpoint_form_validate'
_dfp_breakpoint_form in ./dfp.admin.inc
Helper form builder for an individual breakpoint.

File

./dfp.admin.inc, line 495
Admin forms and functinality for DFP ads.

Code

function dfp_breakpoint_form_validate($element, &$form_state) {
  if (empty($element['browser_size']['#value']) && !empty($element['ad_sizes']['#value'])) {
    form_error($element['browser_size'], t('The browser size cannot be empty if ad size(s) exists.'));
  }
  elseif (!empty($element['browser_size']['#value']) && empty($element['ad_sizes']['#value'])) {
    form_error($element['ad_sizes'], t('The ad size(s) cannot be empty if a browser size exists.'));
  }
  if (!empty($element['browser_size']['#value']) && !empty($element['ad_sizes']['#value'])) {
    if (preg_match('/[^x|0-9]/', $element['browser_size']['#value'])) {
      form_error($element['browser_size'], t('The browser size can only contain numbers and the character x.'));
    }
    elseif (preg_match('/[^x|,|0-9]/', $element['ad_sizes']['#value'])) {
      form_error($element['ad_sizes'], t('The ad size(s) can only contain numbers, the character x and commas.'));
    }
  }
}