Hello All,

I have to validate the URL, am using the "valid_url" API from DRUPAL.

	if (valid_url($webURL)) {
		$message = "Invalid Web URL";
		form_set_error('url', $message);
	}

If i try http://yahoo.com it shows me error, whereas its valid URL.

I think this is not working for me.

Please tell me, how i have to invoke, or am wrong somewhere?

Comments

paddy_deburca’s picture

The valid_url function checks for both absolute and relative URLs - and it defaults to relative.

Please update you code to

if (valid_url($webURL, TRUE)) {
  $message = "Invalid Web URL";
  form_set_error('url', $message);
}

Paddy.

http://deburca.org, and http://amadain.net

tmsimont’s picture

probably because the comment is from 3 years ago...

the right link:
http://api.drupal.org/api/drupal/includes--common.inc/function/valid_url/6

-trevor