Yeah, you'll have to link the ID number up with a 3rd party service that will query the additional information
A South African person identification number is a 13-digit number containing only numeric characters, and no whitespace, punctuation, or alpha characters. It is defined as follows:
YYMMDDGSSSCAZ
YYMMDD : Date of birth (DOB)
G : Gender. 0-4 Female; 5-9 Male
SSS : Sequence No. for DOB/G combination
C : Citizenship. 0 SA; 1 Other
A : Usually 8, or 9 but can be other values
Z : Calculated control (check) digit
The control digit (Z) is calculated as follows:
Using ID Number 8001015009087 as an example:
Add all the digits in the odd positions (excluding last digit).
8 + 0 + 0 + 5 + 0 + 0 = 13 .............................[1]
Move the even positions into a field and multiply the number by 2.
011098 x 2 = 22196 .....................................[2]
Add the digits of the result in [2].
2 + 2 + 1 + 9 + 6 = 20 .................................[3]
Add the answer in [3] to the answer in [1].
13 + 20 = 33 ...........................................[4]
Subtract the second digit of [4](i.e. 3) from 10. The number must tally with the last number in the ID Number. If the result is 2 digits, the last digit is used to compare against the last number in the ID Number. If the answer differs, the ID number is invalid.
Code:
// This method assumes that the 13-digit id number has
// valid digits in position 0 through 12.
// Stored in a property 'ParseIdString'.
// Returns: the valid digit between 0 and 9, or
// -1 if the method fails.
private int GetControlDigit()
{
int d = -1;
try { int a = 0;
for(int i = 0; i < 6; i++)
{
a += int.Parse(this.ParsedIdString[2*i].ToString());
}
int b = 0;
for(int i = 0; i < 6; i++)
{
b = b*10 + int.Parse(this.ParsedIdString[2*i+1].ToString());
}
b *= 2;
int c = 0;
do
{
c += b % 10;
b = b / 10;
}
while(b > 0);
c += a;
d = 10 - (c % 10);
if(d == 10) d = 0;
}
catch {/*ignore*/} return d;
}