BotDetect Ajax CAPTCHA Documentation

This page is an index of BotDetect Captcha documentation regarding Ajax Captcha validation: code samples, how to guides and Ajax implementation options available in different versions of BotDetect.

Related information can be found in similar pages about jQuery Captcha and JavaScript Captcha.

Ajax CAPTCHA in PHP

There are several different approaches you can take when implementing Ajax Captcha validation of BotDetect PHP Captcha, depending on your Ajax framework of choice and the amount and format of data exchanged by the client and server during Captcha validation through Ajax requests.

jQuery Ajax CAPTCHA Validation

If your PHP website uses jQuery, see BotDetect documentation about jQuery Captcha in PHP.

Getting the CAPTCHA Validation Result as JSON

If you prefer to handle the Ajax client-side workflow of Captcha validation yourself, you can make an Ajax request to the BotDetect Captcha handler validation end-point Url, available through the ValidationUrl property of the BotDetect client-side object.

For example, if you make an Ajax GET request to

FormCaptcha.ValidationUrl + "&i=" + userCaptchaCodeInput // TODO: read input

you will get the Captcha validation result as a simple true or false JSON value.

Partially Submitting the Form to Validate the CAPTCHA

If you prefer a custom Ajax implementation that submits the user Captcha code input to a custom end-point in your server-side PHP code, you just need to ensure that you submit the CaptchaId and InstanceId values (available as Id and InstanceId properties of the BotDetect client-side object) along with the user input.

You can then get the Captcha validation result by passing these extra parameters to the Validate() function of the Captcha class:

// TODO: add these values to the Ajax request on the client-side
$userInput = $_REQUEST['userInput'];
$captchaId = $_REQUEST['captchaId'];
$instanceId = $_REQUEST['instanceId'];

$SampleCaptcha = new Captcha($captchaId);
$isHuman = $SampleCaptcha->Validate($userInput, $instanceId);

A variant of this approach to Ajax Captcha validation is shown in the PHP jQuery AJAX Contact Form CAPTCHA Code Sample.

PHP Built-In BotDetect Ajax CAPTCHA Validation

BotDetect client-side functionality includes built-in Ajax Captcha validation capability, which doesn't require any 3rd party Ajax frameworks. Ajax Captcha validation is performed by implementing handlers for four client-side events triggered through a pre-defined Ajax Captcha validation workflow.

This approach to Ajax Captcha validation is shown in the PHP Built-In BotDetect Ajax CAPTCHA Validation code sample

Ajax CAPTCHA in ASP.NET

There are several different approaches you can take when implementing Ajax Captcha validation of BotDetect ASP.NET Captcha, depending on your Ajax framework of choice and the amount and format of data exchanged by the client and server during Captcha validation through Ajax requests.

jQuery Ajax CAPTCHA Validation

If your website uses jQuery, see BotDetect documentation about jQuery Captcha in ASP.NET.

ASP.NET Ajax CAPTCHA Validation

BotDetect CAPTCHA can be used within ASP.NET Ajax UpdatePanel controls using the same code as in regular ASP.NET forms. However, some additional work is required if BotDetect is not visible on the first page load, but gets added to the page dynamically. This approach is demonstrated in the BotDetect ASP.NET Ajax code sample:

ASP.NET Ajax Version Default Source Code Folder Online Source
ASP.NET Ajax 4.5 C:\Program Files\Lanapsoft\BotDetect 3 CAPTCHA Component\Asp.Net\v4.5\WebApp\ AspNetAjax40CaptchaSample
ASP.NET Ajax 4.0 C:\Program Files\Lanapsoft\BotDetect 3 CAPTCHA Component\Asp.Net\v4.0\WebApp\ AspNetAjax40CaptchaSample
ASP.NET Ajax 1.0 C:\Program Files\Lanapsoft\BotDetect 3 CAPTCHA Component\Asp.Net\v3.5\WebApp\ AspNetAjax10CaptchaSample

ASP.NET Unobtrusive Validation Ajax Captcha

BotDetect Captcha can be validated as part of ASP.NET unobtrusive validation of form fields in both ASP.NET MVC and ASP.NET WebForms applications. This approach to Ajax Captcha validation is shown in the ASP.NET MVC Captcha sample and the ASP.NET 4.5 WebForms Captcha sample.

Getting the CAPTCHA Validation Result as JSON

If you prefer to handle the Ajax client-side workflow of Captcha validation yourself, you can make an Ajax request to the BotDetect Captcha handler validation end-point Url, available through the ValidationUrl property of the BotDetect client-side object.

For example, if you make an Ajax GET request to

FormCaptcha.ValidationUrl + "&i=" + userCaptchaCodeInput // TODO: read input

you will get the Captcha validation result as a simple true or false JSON value.

Partially Submitting the Form to Validate the CAPTCHA

If you prefer a custom Ajax implementation that submits the user Captcha code input to a custom end-point in your server-side ASP.NET code, you just need to ensure that you submit the CaptchaId and InstanceId values (available as Id and InstanceId properties of the BotDetect client-side object) along with the user input.

You can then get the Captcha validation result by passing these extra parameters to the static Validate() method of the BotDetect.Web.CaptchaControl class:

// TODO: add these values to the Ajax request on the client-side
string userInput = Request.Params["userInput"] as string;
string captchaId = Request.Params["captchaId"] as string;
string instanceId = Request.Params["instanceId"] as string;

bool isHuman = BotDetect.Web.CaptchaControl.Validate(captchaId, userInput, 
  instanceId);

A variant of this approach to Ajax Captcha validation is shown in the ASP.NET MVC jQuery Ajax Captcha code sample.

ASP.NET Built-In BotDetect Ajax CAPTCHA Validation

BotDetect client-side functionality includes built-in Ajax Captcha validation capability, which doesn't require any 3rd party Ajax frameworks. Ajax Captcha validation is performed by implementing handlers for four client-side events triggered through a pre-defined Ajax Captcha validation workflow.

This approach to Ajax Captcha validation is explained in the Built-In Ajax Captcha validation implementation how to guide, and shown in the ASP.NET built-in BotDetect Ajax CAPTCHA Validation code sample:

.NET Version Default Source Code Folder Online Source
.NET 4.0 C:\Program Files\Lanapsoft\BotDetect 3 CAPTCHA Component\Asp.Net\v4.0\WebApp\CaptchaAjaxValidationSample
.NET 3.5 C:\Program Files\Lanapsoft\BotDetect 3 CAPTCHA Component\Asp.Net\v3.5\WebApp\CaptchaAjaxValidationSample
.NET 2.0 C:\Program Files\Lanapsoft\BotDetect 3 CAPTCHA Component\Asp.Net\v2.0\WebApp\CaptchaAjaxValidationSample

Ajax CAPTCHA in ASP Classic

There are several different approaches you can take when implementing Ajax Captcha validation of BotDetect Asp Captcha, depending on your Ajax framework of choice and the amount and format of data exchanged by the client and server during Captcha validation through Ajax requests.

jQuery Ajax CAPTCHA Validation

If your Classic ASP website uses jQuery, see BotDetect documentation about jQuery Captcha in ASP Classic.

Getting the CAPTCHA Validation Result as JSON

If you prefer to handle the Ajax client-side workflow of Captcha validation yourself, you can make an Ajax request to the BotDetect Captcha handler validation end-point Url, available through the ValidationUrl property of the BotDetect client-side object.

For example, if you make an Ajax GET request to

FormCaptcha.ValidationUrl + "&i=" + userCaptchaCodeInput // TODO: read input

you will get the Captcha validation result as a simple true or false JSON value.

Partially Submitting the Form to Validate the CAPTCHA

If you prefer a custom Ajax implementation that submits the user Captcha code input to a custom end-point in your server-side ASP code, you just need to ensure that you submit the CaptchaId and InstanceId values (available as Id and InstanceId properties of the BotDetect client-side object) along with the user input.

You can then get the Captcha validation result by passing these extra parameters to the ValidateInstance() function of the Captcha class:

' TODO: add these values to the Ajax request on the client-side
Dim userInput : userInput = Request("userInput")
Dim captchaId : captchaId = Request("captchaId")
Dim instanceId : instanceId = Request("instanceId")

Dim SampleCaptcha : Set Captcha = (New Captcha)(captchaId)
Dim isHuman : isHuman = SampleCaptcha.ValidateInstance(instanceId, userInput)

ASP Classic Built-In BotDetect Ajax CAPTCHA Validation

BotDetect client-side functionality includes built-in Ajax Captcha validation capability, which doesn't require any 3rd party Ajax frameworks. Ajax Captcha validation is performed by implementing handlers for four client-side events triggered through a pre-defined Ajax Captcha validation workflow.

This approach to Ajax Captcha validation is shown in the ASP Built-In BotDetect Ajax CAPTCHA Validation code sample