核心代碼:
驗(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://m.survivalescaperooms.com")%> '****************************** 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 %> 新聞熱點(diǎn)
疑難解答
圖片精選