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

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

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

核心代碼:

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

相關(guān)文章

最新評論