核心代碼:
驗證輸入網址是否有效并可以訪問<% '****************************** '函數:UrlOK(strURL) '參數:strURL,待驗證的網址 '日期:2007/7/13 '描述:驗證輸入網址是否有效并可以訪問 '示例:<%=UrlOK("http://www.49028c.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 = "無效" 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 %>
新聞熱點
疑難解答