ASP Classic Basic CAPTCHA VBScript Code Sample (BotDetect v3.0; deprecated)

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 Classic ASP Captcha and validate the user input.

It can be used as a starting point when you are first learning how to use BotDetect.

Installed 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, Captcha validation using the Validate function.

Please Note

The information on this page is out of date and applies to a deprecated version of BotDetect™ CAPTCHA (v3.0).

An up-to-date equivalent page for the latest BotDetect Captcha release (v4) is BotDetect v4 Captcha documentation index.

General information about the major improvements in the current BotDetect release can be found at the What's New in BotDetect v4.0 page.