You are here

function _ad_eck_validate_url in Advertisement 7.3

Validate the link, eventually setting a form error.

File

./ad.module, line 614
Core code for the ad module.

Code

function _ad_eck_validate_url($element, &$form_state, $form) {
  if (!empty($element['#value'])) {
    $url = $element['#value'];
    if (function_exists('link_validate_url')) {
      $validation = link_validate_url($url);
      if (!$validation) {
        form_error($element, t('Invalid URL.'));
      }
      elseif ($validation == LINK_INTERNAL) {

        // @todo: should we allow internal links?
        form_error($element, t('The URL cannot be internal.'));
      }
    }
  }
}