Possible Duplicate:
What is the best regular expression to check if a string is a valid URL?
i wanted to validate url taken from the user... Like http://www.google.com i wanted to validate last part of the url (.com) i am continuesly searching on web but not found correct answer. my code is
function validate()
{
var url = document.getElementById("url").value;
var pattern = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
if (pattern.test(url)) {
alert("Valid Url");
return true;
}
alert("Please Input Right URL");
return false;
}