核心代码:
验证输入网址是否有效并可以访问
<%
'******************************
'函数:urlok(strurl)
'参数:strurl,待验证的网址
'日期:2007/7/13
'描述:验证输入网址是否有效并可以访问
'示例:<%=urlok("http://www.jb51.net")%>
'******************************
function urlok(strurl)
on error resume next
if strurl<>"" then
set objhttp = createobject("msxml2.xmlhttp")
objhttp.open "get", strurl, false
objhttp.send
if instr(objhttp.statustext,"ok") then
urlok = "有效"
else
urlok = "无效"
end if
else
urlok = "错误:您没有输入网址!"
end if
end function
%>
正则验证输入网址是否合法的url
<%
'******************************
'函数:checkexp(patrn,strng)
'参数:patrn 正则表达式;strng 验证字符串
'作者:阿里西西
'日期:2007/7/13
'描述:正则验证输入网址是否合法的url
'示例:<%=checkexp(patrn,strng)%>
'******************************
function checkexp(patrn,strng)
dim regex,match
set regex = new regexp ' 建立正则表达式。
regex.pattern = patrn ' 设置模式。
regex.ignorecase = true ' 设置是否区分字符大小写。
regex.global = true ' 设置全局可用性。
matches = regex.test(strng)
checkexp = matches
end function
%>
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!