The actual UIDAI-Aadhaar number is 11 digits and not 12 digits. Well, do not be surprised.

The first 11 digits of the 12 digit Aadhaar number displayed on your Aadhaar card is the actual UID Number and the 12th digit is the checksum associated with Verhoeff Algorithm scheme.

What is Checksum?

The checksum is the last digit in the number series of a number, through which data-entry errors can be eliminated to a large extent.

The purpose of check digits is simple. Any time identifiers (typically number +/- letters) are being manually entered via keyboard, there will be errors. Inadvertent keystrokes or fatigue can cause digits to be rearranged, dropped, or inserted. The most common example is of misdialing phone numbers.

Check digits help to reduce the likelihood of errors by introducing a final digit that is calculated from the prior digits. Using the proper algorithm, the final digit can always be calculated. Therefore, when a number is entered into the system (manually or otherwise), the computer can instantly verify that the final digit matches the digit predicted by the check digit algorithm. If the two do not match, the number is refused. The end result is fewer data entry errors.

In today’s world, two checksum algorithms are widely used. There are

01) Luhn algorithm.

02) Verhoeff algorithm.

The Luhn Algorithm’s most common usage is in the generation of credit card numbers.

The Verhoeff algorithm’s most common usage is in the UIDAI-Aadhaar number generation program.

The Verhoeff algorithm is a complicated one, and cannot be calculated manually. This is suitable for computer-era.

The Verhoeff algorithm, a checksum formula for error detection first published in 1969, was developed by Dutch mathematician Jacobus Verhoeff (born 1927). Like the more widely known Luhn algorithm, it works with strings of decimal digits of any length. It detects all single-digit errors and all transposition errors involving two adjacent digits.

As 100 crores+ Aadhaar numbers will be generated, the Verhoeff Algorithm was the chosen one. And, it is not expected that any one will try to manually validate the Aadhaar number.

Aadhaar number is a random generated number, with no preset formula like the other Indian numbers, be it Pin code, IT PAN, Passport Number or Bank Account number.

So if you wants to create your function to validate the Aadhaar number than you can follow Verhoeff algorithm. Below you can find out the javascript way of making it possible to validate Aadhaar number

```// verhoeff check is the string method that is validating the aadhaar card number
// In alert it will return true or false as per the validations
```

Verhoeff algorithm js required to use aadhaar number validation

```// Verhoeff algorithm
var Verhoeff = {
"d":[[0,1,2,3,4,5,6,7,8,9],
[1,2,3,4,0,6,7,8,9,5],
[2,3,4,0,1,7,8,9,5,6],
[3,4,0,1,2,8,9,5,6,7],
[4,0,1,2,3,9,5,6,7,8],
[5,9,8,7,6,0,4,3,2,1],
[6,5,9,8,7,1,0,4,3,2],
[7,6,5,9,8,2,1,0,4,3],
[8,7,6,5,9,3,2,1,0,4],
[9,8,7,6,5,4,3,2,1,0]],
"p":[[0,1,2,3,4,5,6,7,8,9],
[1,5,7,6,2,8,3,0,9,4],
[5,8,0,3,7,9,6,1,4,2],
[8,9,1,6,0,4,3,5,2,7],
[9,4,5,3,1,2,6,8,7,0],
[4,2,8,6,5,7,3,9,0,1],
[2,7,9,3,8,0,6,4,1,5],
[7,0,4,6,9,1,3,2,5,8]],
"j":[0,4,3,2,1,5,6,7,8,9],
"check":function(str)
{
var c = 0;
str.replace(/\D+/g,"").split("").reverse().join("").replace(/[\d]/g, function(u, i, o){
c = Verhoeff.d[c][Verhoeff.p[i&7][parseInt(u,10)]];
});
return (c === 0);

},
"get":function(str){
var c = 0;
str.replace(/\D+/g,"").split("").reverse().join("").replace(/[\d]/g, function(u, i, o){
c = Verhoeff.d[ c ][ Verhoeff.p[(i+1)&7][parseInt(u,10)] ];
});
return Verhoeff.j[c];
}
};

// Verhoeff algorithm validator, by Avraham Plotnitzky. (aviplot at gmail)
String.prototype.verhoeffCheck = (function()
{
var d = [[0,1,2,3,4,5,6,7,8,9],
[1,2,3,4,0,6,7,8,9,5],
[2,3,4,0,1,7,8,9,5,6],
[3,4,0,1,2,8,9,5,6,7],
[4,0,1,2,3,9,5,6,7,8],
[5,9,8,7,6,0,4,3,2,1],
[6,5,9,8,7,1,0,4,3,2],
[7,6,5,9,8,2,1,0,4,3],
[8,7,6,5,9,3,2,1,0,4],
[9,8,7,6,5,4,3,2,1,0]];
var p = [[0,1,2,3,4,5,6,7,8,9],
[1,5,7,6,2,8,3,0,9,4],
[5,8,0,3,7,9,6,1,4,2],
[8,9,1,6,0,4,3,5,2,7],
[9,4,5,3,1,2,6,8,7,0],
[4,2,8,6,5,7,3,9,0,1],
[2,7,9,3,8,0,6,4,1,5],
[7,0,4,6,9,1,3,2,5,8]];
var j = [0,4,3,2,1,5,6,7,8,9];

return function()
{
var c = 0;
this.replace(/\D+/g,"").split("").reverse().join("").replace(/[\d]/g, function(u, i, o){
c = d[c][p[i&7][parseInt(u,10)]];
});
return (c === 0);
};
})();

// Verhoeff algorithm producer, by Avraham Plotnitzky. (aviplot at gmail)
String.prototype.verhoeffGet = (function()
{
var d = [[0,1,2,3,4,5,6,7,8,9],
[1,2,3,4,0,6,7,8,9,5],
[2,3,4,0,1,7,8,9,5,6],
[3,4,0,1,2,8,9,5,6,7],
[4,0,1,2,3,9,5,6,7,8],
[5,9,8,7,6,0,4,3,2,1],
[6,5,9,8,7,1,0,4,3,2],
[7,6,5,9,8,2,1,0,4,3],
[8,7,6,5,9,3,2,1,0,4],
[9,8,7,6,5,4,3,2,1,0]];
var p = [[0,1,2,3,4,5,6,7,8,9],
[1,5,7,6,2,8,3,0,9,4],
[5,8,0,3,7,9,6,1,4,2],
[8,9,1,6,0,4,3,5,2,7],
[9,4,5,3,1,2,6,8,7,0],
[4,2,8,6,5,7,3,9,0,1],
[2,7,9,3,8,0,6,4,1,5],
[7,0,4,6,9,1,3,2,5,8]];
var j = [0,4,3,2,1,5,6,7,8,9];

return function()
{
var c = 0;
this.replace(/\D+/g,"").split("").reverse().join("").replace(/[\d]/g, function(u, i, o){
c = d[c][p[(i+1)&7][parseInt(u,10)]];
});
return j[c];
};
})();
```