Created
October 23, 2012 13:29
-
-
Save ziyahan/3938741 to your computer and use it in GitHub Desktop.
TC Kimlik No Doğrulama Algoritması
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tckimlik(kno) { | |
var desen = /^[0-9]{11,11}/; | |
if ((kno).match(desen)) { | |
if (Number(kno.charAt(0)) == 0) { | |
return false; | |
} | |
var tekler = Number(kno.charAt(0)) + Number(kno.charAt(2)) + Number(kno.charAt(4)) + Number(kno.charAt(6)) + Number(kno.charAt(8)); | |
var ciftler = Number(kno.charAt(1)) + Number(kno.charAt(3)) + Number(kno.charAt(5)) + Number(kno.charAt(7)); | |
var basamak10 = (tekler * 7 - ciftler) % 10; | |
var toplam = (tekler + ciftler + Number(kno.charAt(9))) % 10; | |
if (basamak10 != Number(kno.charAt(9))) { | |
return false; | |
} | |
if (toplam != Number(kno.charAt(10))) { | |
return false; | |
} else return true; | |
} else return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment