欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp 驗(yàn)證輸入網(wǎng)址是否有效并可以訪問(wèn) 與正則驗(yàn)證輸入網(wǎng)址

 更新時(shí)間:2007年08月08日 11:48:35   投稿:mdxy-dxy  
這篇文章主要是驗(yàn)證用戶輸入的字符是否是網(wǎng)址的方法,需要的朋友可以參考一下

核心代碼:

驗(yàn)證輸入網(wǎng)址是否有效并可以訪問(wèn)
<% 
'****************************** 
'函數(shù):UrlOK(strURL) 
'參數(shù):strURL,待驗(yàn)證的網(wǎng)址 
'日期:2007/7/13 
'描述:驗(yàn)證輸入網(wǎng)址是否有效并可以訪問(wèn) 
'示例:<%=UrlOK("http://www.dbjr.com.cn")%> 
'****************************** 
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 = "無(wú)效" 
 End if 
Else 
 UrlOK = "錯(cuò)誤:您沒(méi)有輸入網(wǎng)址!" 
End If 
End Function 
%>
正則驗(yàn)證輸入網(wǎng)址是否合法的URL
<% 
'****************************** 
'函數(shù):checkexp(patrn,strng) 
'參數(shù):patrn 正則表達(dá)式;strng 驗(yàn)證字符串 
'作者:阿里西西 
'日期:2007/7/13 
'描述:正則驗(yàn)證輸入網(wǎng)址是否合法的URL 
'示例:<%=checkexp(patrn,strng)%> 
'****************************** 
function checkexp(patrn,strng) 
dim regex,match 
set regex = new regexp ' 建立正則表達(dá)式。 
regex.pattern = patrn ' 設(shè)置模式。 
regex.ignorecase = true ' 設(shè)置是否區(qū)分字符大小寫(xiě)。 
regex.global = true ' 設(shè)置全局可用性。 
matches = regex.test(strng) 
checkexp = matches 
end function 
%> 

相關(guān)文章

最新評(píng)論