Blog Archives
Javascript – Validate URL function
Function:
function checkUrl(theUrl){
if(theUrl.indexOf(“http://”)!=-1 || theUrl.indexOf(“https://”)!=-1 || theUrl.indexOf(“www.”)!=-1){
return true;
} else {
alert(“Wrong address.”);
return false;
}
}
Function call:
var url = “http://google.com/”;
alert(checkUrl(url));