The CheckValidUrl() function takes in an URL and checks whether or not it is valid by verifying it against a regular expression. Works for HTTP, HTTPS and FTP URLs.
function CheckValidUrl(strUrl)
{
var RegexUrl = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
return RegexUrl.test(strUrl);
}
// Sample use
alert(CheckValidUrl("http://www.geekpedia.com"));