JS校验url地址

var Utils = {
 isUrl : function(str_url) {
  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);
  //re.test()
  if (re.test(str_url)) {
   return true;
  } else {
   return false;
  }
 }
};


你可能感兴趣的:(javascript,随记)