【转】JS判断URL
function isURL() {
var strRegex =
"^((https|http|ftp|rtsp|mms)://)?[a-z0-9A-Z]{3}\.[a-z0-9A-Z][a-z0-9A-Z]{0,61}?[a-z0-9A-Z]\.com|net|cn|cc
(:s[0-9]{1-4})?/$";
var re = new RegExp(strRegex);
if (re.test(document.getElementById("<%=txtServerIP.ClientID %>").value)) {
alert("成功");
return true;
} else {
alert("失败");
return false;
}
}
这个比较好:
^((https|http)://)?[w|W]{3}\.[a-z0-9A-Z]+\.(com|net|cn|com\.cn){1}(/([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*)?$