REGEXVAULTv2.0
Identity & PII/National Identity Numbers
Verified Safe

Indian Aadhaar Number Regex for JavaScript

/^[2-9][0-9]{3}[\s-]?[0-9]{4}[\s-]?[0-9]{4}$/

What this pattern does

This page provides a well-structured, multi-part regular expression for matching indian aadhaar number, ported and verified for JavaScript. Identity and credential patterns need both correctness and safety, since they're frequent targets for adversarial input. The snippet below is ready to drop into your JavaScript project — whether you're validating in an Express middleware, a Next.js API route, or a client-side form.

Javascript Implementation

Javascript
// Indian Aadhaar Number
// ReDoS-safe | RegexVault — Identity & PII > National Identity Numbers

const indianAadhaarNumberRegex = /^[2-9][0-9]{3}[\s-]?[0-9]{4}[\s-]?[0-9]{4}$/;

function validateIndianAadhaarNumber(input: string): boolean {
  return indianAadhaarNumberRegex.test(input);
}

// Example
console.log(validateIndianAadhaarNumber("234567890123")); // true

Test Cases

Matches (Valid)
Rejects (Invalid)
234567890123034567890123
2345 6789 0123134567890123
2345-6789-012323456789012
9999 9999 99992345678901234
ABCD 5678 9012

When to use this pattern

This pattern is drawn from the Identity & PII > National Identity Numbers category and carries a ReDoS-safe certification. That matters for JavaScript developers because especially critical in long-running Node.js event loops where a ReDoS vulnerability can block the entire process. RegexVault audits patterns against known backtracking attack vectors, ensuring you have the necessary context before using this regex in a high-stakes production environment.

Common Pitfalls

Aadhaar numbers must not be publicly displayed or shared without consent under the Aadhaar Act. UIDAI provides a Masked Aadhaar format (XXXX XXXX 1234) for semi-public use. Virtual IDs (VID) are the preferred sharing mechanism.

Technical Notes

Aadhaar UIDs are issued by UIDAI to Indian residents. First digit cannot be 0 or 1 (a design choice to avoid confusion). The 12-digit number uses a Verhoeff checksum algorithm. Display format is typically XXXX XXXX XXXX.

Have a pattern that belongs in the vault?

Submit it for review — community-verified patterns get credited to your GitHub handle. Free submissions join the queue. Priority review available for $15.

Submit a Pattern