ASP Classic Basic CAPTCHA VBScript Code Sample
First Time Here?
Check the BotDetect Developer Crash Course for key integration steps.
The ASP Classic Basic Captcha code sample shows the most basic source code required to protect a Classic ASP form with BotDetect CAPTCHA and validate the user input.
It can be used as a starting point when you are first learning how to use BotDetect.
Download the BotDetect Classic ASP CAPTCHA Component and run this sampleInstalled Location
By default, the Classic ASP basic Captcha code sample is installed at:
C:\Program Files\Lanapsoft\BotDetect 3 CAPTCHA Component\Asp\WebApp\AspBasicCaptchaSample
You can also run it from the BotDetect Start Menu:
Programs > Lanapsoft > BotDetect 3 CAPTCHA Component > ASP > Web Applications > Run
Default.asp
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www. w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>BotDetect CAPTCHA Basic ASP Sample</title> <link type="text/css" rel="Stylesheet" href="StyleSheet.css" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <!-- #include file ="BotDetect.asp" --> </head> <body> <form method="post" action="" id="form1"> <h1>BotDetect CAPTCHA Basic ASP Sample</h1> <fieldset> <legend>ASP CAPTCHA validation</legend> <label for="CaptchaCode">Retype the characters from the picture: </label> <% ' Adding BotDetect CAPTCHA to the page Dim SampleCaptcha : Set SampleCaptcha = (New Captcha)("SampleCaptcha") SampleCaptcha.UserInputID = "CaptchaCode" Response.Write SampleCaptcha.Html %> <div class="validationDiv"> <input name="CaptchaCode" type="text" id="CaptchaCode" /> <input type="submit" name="ValidateCaptchaButton" value="Validate" id="ValidateCaptchaButton" /> <% ' CAPTCHA user input validation (only if the form was submitted) If Request.ServerVariables("REQUEST_METHOD") = "POST" Then Dim isHuman : isHuman = SampleCaptcha.Validate() If Not isHuman Then ' CAPTCHA validation failed, show error message Response.Write "<span class=""incorrect"">Incorrect code </span>" Else ' CAPTCHA validation passed, perform protected action Response.Write "<span class=""correct"">Correct code </span>" End If End If %> </div> </fieldset> </form> </body> </html>
After including the BotDetect Captcha library, adding Captcha protection to the form is as simple as creating a Captcha object instance and printing the Html function result. The same object instance provides easy Captcha validation using the Validate function.
Current BotDetect Versions
- BotDetect PHP CAPTCHA v3.0.Beta12013 May 20
- BotDetect ASP.NET CAPTCHA v3.0.142013 May 20
- BotDetect ASP Classic CAPTCHA v3.0.142013 May 20



