Validation for Indian forms

Validate Indian IDs in one line.

PAN, GSTIN, IFSC, PIN code, mobile and Aadhaar. Add one import to the form you already have, and IndiaVal checks every field and explains mistakes in plain English.

$npm install indiaval

Zero dependencies. TypeScript types included. Works with any framework, or none.

Try it

Type into any field. These are IndiaVal's real checks.

Everything runs in your browser. Nothing you type is sent anywhere. Please don't enter real Aadhaar numbers here; use the sample.

One line, then you're done.

No per-field code. IndiaVal finds your fields by name, or by a data attribute, and shows errors through the browser's own form validation.

1Install

npm install indiaval

Or skip the install and use a script tag, shown below.

2Import

import 'indiaval/auto';

Fields named pan, gstin, ifsc, pincode, mobile or aadhaar are validated straight away. Anything added to the page later is picked up too.

3Or mark a field yourself

<input name="tax_id" data-indiaval="pan">

A plain pin field is often a security PIN, and phone may be a landline, so add data-indiaval to those if you want them checked.

No build tool? Use one script tag:

<script type="module" src="https://cdn.jsdelivr.net/npm/indiaval/src/auto.js"></script>

What it checks.

Format and checksums, instantly, with no network call.

PAN

ABCPE1234F

Ten characters in the right pattern, with a valid holder-type letter (individual, company, firm and so on).

GSTIN

27AAPFU0939F1ZV

Fifteen characters, a real state code, a valid PAN inside, and the checksum character.

IFSC

SBIN0001234

Four-letter bank code, the zero, and a six-character branch code.

PIN code

110092

Six digits, no leading zero, with the postal region read from the first digit.

Mobile

+91 98765 43210

Accepts the ways people actually type it, starts with 6 to 9, and rejects placeholders like 9999999999.

Aadhaar

2345 6789 0124

Twelve digits, first digit 2 to 9, and the Verhoeff checksum. Gives a masked form that is safe to show or log.

What it does not do.

IndiaVal checks format and checksums only. A valid result means the ID could exist. It cannot tell you that the ID was issued, or that it belongs to the person in front of you. Only the issuing authority's own verification service can do that.

It is open source under the MIT licence. Read the code, report a problem, or suggest a validator on GitHub.