Click here to Skip to main content
15,849,197 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am going to validate the given aadhaar number in valid one or invalid this only i don't need the other details, like the validation might be used for some algorithm that's what i asking..!

What I have tried:

I am going to validate the given aadhaar number in valid one or invalid this only i don't need the other details, like the validation might be used for some algorithm that's what i asking..!
Posted
Updated 29-Oct-20 8:08am
v2

Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...

A very quick search gave over 350,000 results: aadhaar number validation php - Google Search[^]

In future, please try to do at least basic research yourself, and not waste your time or ours.
 
Share this answer
 
Comments
vengateshwaran 4-Jan-18 8:04am    
function checkUID(e) {
/*e.preventDefault();*/
var uid = $('#aadhaar_number').val();
/*console.log(uid);*/
if (uid.length != 12) {
return false;
}

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) {
c = Verhoeff.d[c][Verhoeff.p[i % 8][parseInt(u, 10)]];
});
return c;

},
"get": function (str) {

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

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]];

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

if (Verhoeff['check'](uid) === 0) {
/*return true;*/
alert('Match Found..!');
} else {
/*return false;*/
alert('Match Not Found..!');
}
}
vengateshwaran 4-Jan-18 8:05am    
Thank you all
This may help - Stackoverflow[^]
 
Share this answer
 
Comments
vengateshwaran 4-Jan-18 8:05am    
function checkUID(e) {
/*e.preventDefault();*/
var uid = $('#aadhaar_number').val();
/*console.log(uid);*/
if (uid.length != 12) {
return false;
}

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) {
c = Verhoeff.d[c][Verhoeff.p[i % 8][parseInt(u, 10)]];
});
return c;

},
"get": function (str) {

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

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]];

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

if (Verhoeff['check'](uid) === 0) {
/*return true;*/
alert('Match Found..!');
} else {
/*return false;*/
alert('Match Not Found..!');
}
}
vengateshwaran 4-Jan-18 8:05am    
Thank you all

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900