You are here

function form_validate_url in Form Builder 7

Same name and namespace in other branches
  1. 6 form_builder.module \form_validate_url()
  2. 7.2 form_builder.module \form_validate_url()

Generic validation function to check for a valid url value.

File

./form_builder.module, line 411
form_builder.module Generic form building framework and user interface.

Code

function form_validate_url(&$element, &$form_state) {
  if (empty($element['#value'])) {
    return;
  }
  if (!valid_url($element['#value'], isset($element['#absolute_url']) ? $element['#absolute_url'] : TRUE)) {
    form_error($element, t('The %title field value must be a valid URL.', array(
      '%title' => $element['#title'],
    )));
  }
}