ASP Classic Basic CAPTCHA VBScript Code Example (BotDetect ASP v4.x; discontinued)

First Time Here?

Check the BotDetect Developer Crash Course for key integration steps.

The ASP Classic Basic Captcha code example 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 example

Installed Location

By default, the Classic ASP basic Captcha code example is installed at:
C:\Program Files\Captcha Inc\BotDetect 4 CAPTCHA Component\Asp\WebApp\AspBasicCaptchaExample

You can also run it from the BotDetect Start Menu:
Programs > Captcha Inc > BotDetect 4 CAPTCHA Component > ASP > Web Applications > Run


<!-- #include file ="BotDetect.asp" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">

<html xmlns="" >
  <title>BotDetect ASP Classic CAPTCHA Validation: Basic ASP CAPTCHA Code 
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <link type="text/css" rel="Stylesheet" href="<%= CaptchaUrls.LayoutStylesheetUrl() %>" />
  <link type="text/css" rel="Stylesheet" href="StyleSheet.css" />
  <form method="post" action="" class="column" id="form1">

    <h1>BotDetect ASP Classic CAPTCHA Validation: 
    <br /> Basic ASP CAPTCHA Code Example</h1>
        <legend>ASP CAPTCHA validation</legend>
        <label for="CaptchaCode">Retype the characters from the picture:</label>
        <% ' Adding BotDetect CAPTCHA to the page 
          Dim ExampleCaptcha : Set ExampleCaptcha = (New Captcha)("ExampleCaptcha")
          ExampleCaptcha.UserInputID = "CaptchaCode"
          Response.Write ExampleCaptcha.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 sumbitted)
              If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
                Dim isHuman : isHuman = ExampleCaptcha.Validate()
                If Not isHuman Then 
                  ' CAPTCHA validation failed, show error message
                  Response.Write "<span class=""incorrect"">Incorrect code</span>"
                  ' CAPTCHA validation passed, perform protected action
                  Response.Write "<span class=""correct"">Correct code</span>"
                End If 
              End If

After including the BotDetect Captcha library, Captcha validation using the Validate function.

Please Note

The information on this page applies to a discontinued version of BotDetect™ ASP CAPTCHA (v4.x)