Skip to content


re captcha for classic asp in vbscript

If you’d like to use recaptcha on your classic asp pages, you’ll likely find this post in google groups interesting.
Recaptcha, as you may well know, is the project by Carnegie Mellon University that is using the millions of CAPTCHA inputs on websites to digitize books. In fact, it is using human procesing power to digitize those parts that OCR software is having trouble with.
Great Idea!
So, on to making it work with asp:

Response.Write recaptcha_challenge_writer(publickey12)
If Request.ServerVariables(“CONTENT_LENGTH”) <> 0 Then
Dim strReturn
strReturn = recaptcha_confirm(privatekey12,Request.Form(“recaptcha_challenge_field”),Request.Form(“recaptcha_response_field”))
If strReturn <> TRUE Then
Response.Write strReturn
Response.Write “all ok”

‘ returns string the can be written where you would like the reCAPTCHA challenged placed on your page
function recaptcha_challenge_writer(publickey)
Dim str

str = “
recaptcha_challenge_writer = str
end function

function recaptcha_confirm(privkey,rechallenge,reresponse)
‘ Test the captcha field
Dim VarString
VarString = _
“privatekey=” & privkey & _
“&remoteip=” & Request.ServerVariables(“REMOTE_ADDR”) & _
“&challenge=” & rechallenge & _
“&response=” & reresponse

Dim objXmlHttp
Set objXmlHttp = Server.CreateObject(“Msxml2.ServerXMLHTTP”) “POST”, “”,False
objXmlHttp.setRequestHeader “Content-Type”, “application/x-www-form-urlencoded”
objXmlHttp.send VarString

Dim ResponseString
ResponseString = split(objXmlHttp.responseText, vblf)
Set objXmlHttp = Nothing
if ResponseString(0) = “true” then
‘They answered correctly
recaptcha_confirm = TRUE
‘They answered incorrectly
recaptcha_confirm = ResponseString(1)
end if
end function

Be Sociable, Share!

Posted in code.

Tagged with , , , , .

3 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Kenny says

    How do I get the actual CAPTCHA part to show up on my asp page above the submit button? You posted the above code with no further instruction?

  2. admin says

    Hi Kenny,
    the function recaptcha_challenge_writer calls a Javascript provided by recpatcha that will make the actual image show up on your site.
    You’ll find all the info at

  3. tweety says

    Hi there.

    I know this is quite an old post, but am curious to solve my issue.
    I am trying to implement recaptcha for my asp form. the form has more than 35 fields and is divided into 4 sections.
    To call the form I am using a function Outputform and to save the form I am using another function Saveform. I am calling these two functions based on Request method of the page, ie; “POST”. If request method is not post, it would display the form if not it will save the form.
    Now my problem is I am unable to implement the captcha script with my code. So can you please help me with this. I can email you more details if you need.

    Thank you so much for your time.

Some HTML is OK

or, reply to this post via trackback.