function url_validate_url in URL field 7
This is a copy of the form_validate_url() function from Drupal 8.
Note that #maxlength and #required is validated by _form_validate() already.
1 string reference to 'url_validate_url'
- url_field_widget_form in ./
url.module - Implements hook_field_widget_form().
File
- ./
url.module, line 369 - Provides a URL field type that stores external links with optional titles.
Code
function url_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,
)));
}
}