By validate I mean check if its a URL that exists and does not some random stuff typed into the form
The above script gives me:
msxml3.dll (0x800C0005)
The system cannot locate the resource specified.
Main Topics
Browse All TopicsHi,
I need an ASP funnction that can validate a URL from a form.
Could you pls direct me to one.
Thanx
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Here's an example - http://levinecentral.com/t
Here's the source:
<html>
<head><title>Check if URL exists</title></head>
<body>
<form method="POST" action="url_exists.asp">
<p><input type="text" name="formURL" size="40" value="<%=request.form("fo
<p><input type="submit" value="Check" name="B1"></p>
<%
if request.form("formURL") > "" then
response.write("<hr><br>")
Dim objXMLHTTP, strReturnStatus
Set objXMLHTTP = Server.CreateObject("Micro
objXMLHTTP.Open "GET", request.form("formURL"), False
objXMLHTTP.Send
strReturnStatus = objXMLHTTP.Status
Set objXMLHTTP = Nothing
if strReturnStatus = "200" then
response.write("URL " & request.form("formURL") & " was found.")
else
response.write("URL " & request.form("formURL") & " was NOT found.")
end if
end if
%>
</form>
</body>
</html>
Here's the same code with an "on error" to handle missing domains..
<html>
<head><title>Check if URL exists</title></head>
<body>
<form method="POST" action="url_exists.asp">
<p><input type="text" name="formURL" size="40" value="<%=request.form("fo
<p><input type="submit" value="Check" name="B1"></p>
<%
On Error Resume Next
if request.form("formURL") > "" then
response.write("<hr><br>")
Dim objXMLHTTP, strReturnStatus
Set objXMLHTTP = Server.CreateObject("Micro
objXMLHTTP.Open "GET", request.form("formURL"), False
objXMLHTTP.Send
strReturnStatus = objXMLHTTP.Status
Set objXMLHTTP = Nothing
if strReturnStatus = "200" then
response.write("URL " & request.form("formURL") & " was found.")
else
response.write("URL " & request.form("formURL") & " was NOT found.")
end if
end if
%>
</form>
</body>
</html>
Business Accounts
Answer for Membership
by: ap_sajithPosted on 2006-06-25 at 05:47:15ID: 16978488
What do you mean validate?.. If you want to check the existance of a URL, then use the function below.
w.mysite.c om/index.a sp")
========== ========== ========== ======= w.mysite.c om/index.a sp") ========== ========== ========== ======= --- LHTTP") ---------- ---------- ---------- ---------- ---------- --- ---------- ---------- ---------- ---
<%
Response.write CheckFileExists("http://ww
'=========================
' Function to check if a specified URL exists specified URL
' Usage : Response.write CheckFileExists("http://ww
'=========================
Function CheckFileExists(strURL)
Dim oXMLHTTP ' As Object
Dim strResult ' As String
' Create XMLHTTP Object
'-------------------------
Set oXMLHTTP = CreateObject("Microsoft.XM
' Open connection using "POST" method, asynchronously
'-------------------------
oXMLHTTP.Open "GET", strURL, False
' Send HTTP request to the server
'-------------------------
oXMLHTTP.Send
' Error Check
'---------------
If Err.Number = 0 Then
' Wait to receive response from server
'-------------------------
strResult = oXMLHTTP.responseText
End If
' Cleanup
'----------
Set oXMLHTTP = nothing
' Return the response to the caller
'-------------------------
If strResult<>"" Then
CheckFileExists = True
Else
CheckFileExists = False
End If
End Function
%>
Hope this helps...
Cheers!