I've got this in my weblinks.module file:

  $form['url'] = array(
    '#type' => 'textfield',
    '#title' => t('URL - MUST include http://www.'),
    '#default_value' => $node->url,
    '#maxlength' => 255,
    '#description' => t('The description can provide additional information about the link.'),
    '#required' => TRUE,

How can I make it so that it gets checked for a valid url?

Comments

EliseVanLooij’s picture

Use the valid_url() function (http://api.drupal.org/api/function/valid_url/5 in your hook_form_validate() implementation.

ThePiston’s picture

i'm adjusting a module, would I do this?

$form['url'] = array(
'#type' => 'textfield',
'#title' => t('URL - MUST include http://www.!'),
'#default_value' => $node->url,
'#maxlength' => 255,
'#description' => t('This MUST include FULL URL with the http://www!'),
'#required' => TRUE,
'#valid_url($url, $absolute => TRUE)
);