You are here

function iframe_validate_url in Iframe 7

Same name and namespace in other branches
  1. 6 iframe.module \iframe_validate_url()

Function to validate the iframe URL.

1 string reference to 'iframe_validate_url'
iframe_field_widget_form in ./iframe.module
Implements hook_field_widget_form(). depends on the widget-type Field XYZ sub-menu "Edit" (used in the middle for "default" values for each individual instance-item, prefilled, with setting from…

File

./iframe.module, line 800
Defines an iframe field with all attributes.

Code

function iframe_validate_url($element, &$form_state) {
  if (!empty($element['#value'])) {
    if (preg_match('#(^http|\\://)#', $element['#value'])) {
      if (!valid_url($element['#value'], TRUE)) {
        form_error($element, t('Invalid iframe URL.'));
      }
    }
    else {

      # not absolute url
      if (!valid_url($element['#value'], FALSE)) {
        form_error($element, t('Invalid iframe URL.'));
      }
    }
  }
}