VerifyJS

Try Live Demo

Interactive
CAPTCHA Image

Stop bots dead in their tracks.

A lightweight, dependency-free JavaScript CAPTCHA library. Protect your forms from automated spam with a fast, client-side canvas solution.

Release Version Bundle Size MIT License GitHub Stars

Why VerifyJS?

Zero Dependencies

Written in pure Vanilla JS. Keeps your bundle incredibly small and fast.

Highly Customizable

Control character length, toggle numbers, uppercase, and specials.

Canvas Rendered

Generates via HTML5 Canvas, difficult for standard scrapers to read.

Easy Integration

Drop it into any existing form in minutes. Works with any backend.

Installation

Include the minified script directly in your HTML document before the closing </body> tag.

index.html
<script src="https://cdn.jsdelivr.net/gh/sahab-uab/verifyJS@main/core/verify.min.js"></script>

1. HTML Structure

Add the required elements to your form: an image tag for the canvas, an input field, and buttons.

form.html
<div id="captchaForm">
  <!-- Image container for CAPTCHA -->
  <img id="captcha" width="140" height="50" alt="CAPTCHA Challenge" />
  
  <!-- User input field -->
  <input type="text" id="captchaInput" placeholder="Enter code" required />
  
  <!-- Action buttons -->
  <button type="button" onclick="captchaRefresh()">Refresh Code</button>
  <button type="button" onclick="validate()">Submit Form</button>
</div>

2. Initialization & Logic

Initialize VerifyJS with your preferred options and set up the validation check.

app.js
// 1. Configure the CAPTCHA parameters
verifyJS({
  totalDigit: 4,        // Length of the code
  number: true,         // Include numbers (0-9)
  uppercase: false,     // Include uppercase (A-Z)
  specialsCharacter: false, // Include specials (!@#)
  width: 140,           // Canvas width in px
  height: 50,           // Canvas height in px
}).vJSConfig();

// 2. Render image on page load
window.onload = () => {
  verifyJS().vJSImgSrc("#captcha");
};

// 3. Function to refresh the code
function captchaRefresh() { 
  verifyJS().vJSImgRefreshSrc("#captcha"); 
}

// 4. Function to validate user input
function validate() { 
  const input = document.getElementById("captchaInput").value;
  const isValid = verifyJS().vJSCheck(input);
  
  if (isValid) {
    alert("Success! Form submitted.");
  } else {
    alert("Invalid code. Try again.");
  }
}

Configuration Options

Option Type Description
totalDigit Number Total number of characters to generate.
number Boolean Allows numeric digits (0-9) in the challenge.
uppercase Boolean Allows uppercase alphabets (A-Z).
specialsCharacter Boolean Allows special characters (e.g., @, #, $).
width / height Number Dimensions of the generated canvas image in pixels.

Community & Support

VerifyJS is an open-source project. We highly value your feedback and contributions!