Page 4 of 4

Re: [Release] Online NRIC Generator

Posted: Sun Feb 21, 2010 3:58 pm
by dktan89
i've been like, using that for the past 3 months

Re: [Release] Online NRIC Generator

Posted: Thu Feb 25, 2010 6:06 pm
by FrozeNn
iSean wrote:Nope.....
I think you are a bit crazy...
It is always ends with 4 Digits Number...
Mine is
970314-10-XXXX
Birthdate - Country BP No. - The Number of People had made this Card (If Not wrong :P)

Here is the link of MyKad :P
http://en.wikipedia.org/wiki/MyKad
Regarding to your MyKad's Number, You're from Selangor haa?? =D
Lets hang out someday = )

Re: [Release] Online NRIC Generator

Posted: Thu Feb 25, 2010 9:58 pm
by Xia0ZaiZai
Helps onli on IC?

Re: [Release] Online NRIC Generator

Posted: Thu Feb 25, 2010 10:03 pm
by NoobHacker
iSean wrote:Nope.....
I think you are a bit crazy...
It is always ends with 4 Digits Number...
Mine is
970314-10-XXXX
Birthdate - Country BP No. - The Number of People had made this Card (If Not wrong :P)

Here is the link of MyKad :P
http://en.wikipedia.org/wiki/MyKad
LOL
i mean ends with is
XXXXXX-XX-XXXA
A = my endswith

Re: [Release] Online NRIC Generator

Posted: Fri Feb 26, 2010 12:23 am
by hairyhacker
iSean wrote:WTF? there's algorithm inside a javascript?
Ya...there is an algorithm in javascript.
According to http://www.samliew.com/Resources/Downlo ... index.html source code to validate NRIC,

Code: Select all

function validate() {
	var ic = document.form.textfield.value;
	if (ic.length != 9) { 
		//alert("Please enter the IC number in the format:\n   SXXXXXXXA");
		document.form.textfield.focus();
		return;
		//return false;
	}
	
	var icArray = new Array(9);
	for(i = 0; i < 9; i++) {
		icArray[i] = ic.charAt(i);
	}
	
	icArray[1] *= 2;
	icArray[2] *= 7;
	icArray[3] *= 6;
	icArray[4] *= 5;
	icArray[5] *= 4;
	icArray[6] *= 3;
	icArray[7] *= 2;
	
	var weight = 0;
	for(i = 1; i < 8; i++) {
		weight += parseInt(icArray[i]);
	}
	
	var offset=(icArray[0]=="T"||icArray[0]=="G")?4:0;
	var temp=(offset+weight)%11;
	
	var st=Array("J","Z","I","H","G","F","E","D","C","B","A");
	var fg=Array("X","W","U","T","R","Q","P","N","M","L","K");
	
	var theAlpha;
	if     (icArray[0]=="S"||icArray[0]=="T") { theAlpha=st[temp]; }
	else if(icArray[0]=="F"||icArray[0]=="G") { theAlpha=fg[temp]; }
	
	if (icArray[8] != theAlpha) {
		document.getElementById("image").src="cross.gif";
		//alert("Bad IC Number: " + ic);
	}
	else {
		document.getElementById("image").src="tick.gif";
		//alert("Good IC Number: " + ic);
	}
}
For Singapore NRIC:
Basically the algorithm is just:
1) Take the first digit, multiply by 2, second digit multiply by 7, third digit by 6, fourth digit by 5, fifth digit by 4, sixth digit by 3, seventh digit by 2. Then you add the total sum together.
For example, the NRIC i entered is S1233457x, you will get a sum of:
1×2+2×7+3×6+4×5+5×4+6×3+7×2=106.

2) Add 4 to the sum if it starts with T or G
3) Divide the sum by 11 and get the remainder.
4) The remainder is corresponding to the number beside the last alphabet of the NRIC:
NRIC starting with S or T: 0=J, 1=Z, 2=I, 3=H, 4=G, 5=F, 6=E, 7=D, 8=C, 9=B, 10=A
NRIC starting with F or G: 0=X, 1=W, 2=U, 3=T, 4=R, 5=Q, 6=P, 7=N, 8=M, 9=L, 10=K

(This is not copied or taken from http://ayumilovemaple.wordpress.com/200 ... ification/, i got it from a professor in NUS last time..)

Solving method example:
Eg: S1234567
1x2
+ 2x7
+ 3x6
+ 4x5
+ 5x4
+ 6x3
+ 7x2
--------------
2+14+18+20+20+18+14 = 106
106/11= 9 R 7 (Last alphabet is D)
Thus, the valid NRIC is S1234567D.

Re: [Release] Online NRIC Generator

Posted: Sun Feb 28, 2010 10:48 pm
by RavenOfDeath
open source.