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

Default.asp

<!-- #include file ="BotDetect.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 ASP Classic CAPTCHA Validation: Basic ASP CAPTCHA Code 
  Example</title>
  <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" />
</head>
<body>
  <form method="post" action="" class="column" id="form1">

    <h1>BotDetect ASP Classic CAPTCHA Validation: 
    <br /> Basic ASP CAPTCHA Code Example</h1>
    
    <fieldset>
        <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>"
                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 applies to a discontinued version of BotDetect™ ASP CAPTCHA (v4.x)