1 form.inc form_validate_url(&$element, &$form_state)

Form element validation handler for #type 'url'.

Note that #maxlength and #required is validated by _form_validate() already.

Related topics

File

core/includes/form.inc, line 4223
Functions for form and batch generation and processing.

Code

function form_validate_url(&$element, &$form_state) {
  $value = trim($element['#value']);
  form_set_value($element, $value, $form_state);

  if ($value !== '' && !valid_url($value, TRUE)) {
    form_error($element, t('The URL %url is not valid.', array('%url' => $value)));
  }
}