function isvalidurl( chars ) {// chars = chars.replace(',',)//var re=/^([hh][tt]{2}[pp]://|[hh][tt]{2}[pp][ss]://)((((w+(-*w*)+).)+((com)|(net)|(edu)|(gov)|(org)|(biz)|(aero)|(coop)|(info)|(name)|(pro)|(museum))(.([a-z]{2}))?)|((w+(-*w*)+).(cn)))$/var re=/^([hh][tt]{2}[pp]://|[hh][tt]{2}[pp][ss]://)(s+.s+)$///var re=/^([hh][tt]{2}[pp]://|[hh][tt]{2}[pp][ss]://)(((((w+(-*w*)+).)+((com)|(net)|(edu)|(gov)|(org)|(biz)|(aero)|(coop)|(info)|(name)|(pro)|(me)|(cc)|(museum)|(cn)|(tv)|(hk))(.([a-z]{2}))?)|((w+(-*w*)+).(cn)))((/|?)s*)*)$/if (!isnull(chars)) {chars = jstrim(chars)if (chars.match(re) == null)return falseelsefunction checkeURL(){
var str=form1.txt.value
//在JavaScript中,正则表达式只能使用"/"开头和结束,不能使用双引号
var Expression=/http(s)?:////([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/
var objExp=new RegExp(Expression)
if(str.indexOf("localhost")){
str = str.replace("localhost","127.0.0.1")
}
if(objExp.test(str)==true){
alert("你输入的URL有效")
return true
}else{
alert('你输入的URL无效')
return false
}
}
function check(){
str = form1.txt.value
str = str.match(/http:\/\/.+/)
if (str == null){
alert('你输入的URL无效')
return false
}else{
return true
}
}