JavaScript

The following tutorial will show you how to integrate Trustcaptcha into JavaScript.

Preparation

Before starting the implementation of Trustcaptcha in your JavaScript project, you should make the following preparations.

Requirements

  • An account with Trustcaptcha and an existing CAPTCHA.
  • A project with JavaScript where Trustcaptcha should be integrated.

Knowledge (recommended)

  • Basic knowledge in JavaScript
  • Understanding of the basic functioning of Trustcaptcha and its implementation in the frontend.

Add Dependency

To use Trustcaptcha, you first need to add the relevant dependencies to your project.

Script

Include the Trustcaptcha script in the head of your webpage.

Use Library

Below you will learn how to use the library.

Trustcaptcha Component

Include the Trustcaptcha component in all desired form elements and specify the site-key. The verification token will be available in the tc-verification-token field after completion of the CAPTCHA and will automatically be transmitted to the server with the other data of your form. Furthermore, you can define what should happen when the CAPTCHA is successfully solved and what should occur in the event of a failure.

Example with Spring and Thymeleaf

The example below shows a possible implementation with Spring and Thymeleaf.
An example including source code can be found on Github.