Skip to content

Instantly share code, notes, and snippets.

@barisesen
Created January 18, 2019 08:34
Show Gist options
  • Save barisesen/ea1931b3a15088f0fa9f48ee4e995852 to your computer and use it in GitHub Desktop.
Save barisesen/ea1931b3a15088f0fa9f48ee4e995852 to your computer and use it in GitHub Desktop.
Tc kimlik numarası doğrulama - javascript
function verify(tcno) {
if (!tcno.match(/^[1-9]{1}[0-9]{9}[0,2,4,6,8]{1}$/)) {
return false;
}
tcno = tcno.split('').map(Number);
var odd = tcno[0] + tcno[2] + tcno[4] + tcno[6] + tcno[8];
var even = tcno[1] + tcno[3] + tcno[5] + tcno[7];
var digit10 = (odd * 7 - even) % 10;
var total = (odd + even + tcno[9]) % 10;
return !(digit10 !== tcno[9] || total !== tcno[10]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment