Monday, November 9, 2009

URL validation + PHP

This is the function which will validate url:

PHP Code:
function isValidURL($url)
{
return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
}

Use of function :

PHP Code:
if(!isValidURL($fldbanner_url))
{
$errMsg .= "* Please enter valid URL including http://
";
}

No comments:

Post a Comment