Skip to content

Instantly share code, notes, and snippets.

View MiktatMertCento's full-sized avatar
🪲
Looking For Bugs

Miktat Mert Cento MiktatMertCento

🪲
Looking For Bugs
View GitHub Profile
@MiktatMertCento
MiktatMertCento / turkishIdNumberValidator.js
Created May 10, 2022 11:05
Turkish: Javascript tc kimlik no doğrulama, English: Javascript turkish identity number validator.
export function tcNoValidate(tcNo) {
tcNo = tcNo.toString();
if (tcNo.length !== 11) return false;
if (tcNo[0] === '0') return false;
let tekToplam = 0, ciftToplam = 0, genelToplam = 0;
for (let i = 0; i < tcNo.length - 2; i++) {
if (i % 2 === 0) {
tekToplam += parseInt(tcNo[i]);
} else {
ciftToplam += parseInt(tcNo[i]);