Usage
This page will show you how to use fakeCAPTCHA.
Add the following code to the
<head>
tag of the page.
<link rel="stylesheet" href="https://fakecaptcha.netlify.app/fakeCAPTCHA/fakeCAPTCHA.css">
<script src="https://fakecaptcha.netlify.app/fakeCAPTCHA/fakeCAPTCHA.js"></script>
Copy
Add the following code where you want to place the CAPTCHA. In the next step, this element will be initialized as a CAPTCHA.
(The
id="captcha"
is an example attribute that you can modify.)
<div id="captcha"></div>
Copy
Use the following code to customize and initialize your CAPTCHA.
<script>
var config = {
element: "#captcha",
textBefore: "I'm not a robot",
textDuring: "Verifying...",
textAfter: "Success",
duration: 2000,
success: true,
dark: false
};
captcha = new CAPTCHA(config);
</script>
Copy
Name |
Type |
Description |
element |
string |
CSS selector for CAPTCHA element. |
textBefore |
string |
Text displayed before verification. |
textDuring |
string |
Text displayed during verification. |
textAfter |
string |
Text displayed after validation. |
duration |
number |
Verification duration time (in milliseconds). |
success |
boolean |
Whether verification is successful. |
dark |
boolean |
Whether CAPTCHA is displayed in dark theme. |
The
checked
property of the CAPTCHA reflects its state. When verification is not started or is in progress, its value is
false
; Otherwise, it is
true
(regardless of whether the verification is successful or not).
<button onclick="alert(captcha.checked);">Get state</button>
Copy