Skip to content

Instantly share code, notes, and snippets.

@iBener
Created April 5, 2017 11:54
Show Gist options
  • Save iBener/9098253588fbca3123388d7f52223083 to your computer and use it in GitHub Desktop.
Save iBener/9098253588fbca3123388d7f52223083 to your computer and use it in GitHub Desktop.
Random T.C. identity number generator.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlsn="http://www.w3.org/1999/xhtml">
<head>
<title>TC NO Üreticisi</title>
<meta http-equiv="content-type" content="text/html" charset="utf-8" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
function getRandomDigit(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function generateTcNo(targetDiv) {
var digits = [];
var tcNo = "";
digits[0] = getRandomDigit(1, 9);
for (i = 1; i < 9; i++) {
digits[i] = getRandomDigit(0, 9);
}
digits[9] = ((digits[0] + digits[2] + digits[4] + digits[6] + digits[8]) * 7 -
(digits[1] + digits[3] + digits[5] + digits[7])) % 10;
digits[10] = (digits[0] + digits[1] + digits[2] + digits[3] + digits[4] + digits[5] +
digits[6] + digits[7] + digits[8] + digits[9]) % 10;
tcNo = digits[0].toString() + digits[1].toString() + digits[2].toString() + digits[3].toString() +
digits[4].toString() + digits[5].toString() + digits[6].toString() + digits[7].toString() +
digits[8].toString() + digits[9].toString() + digits[10].toString();
$("#" + targetDiv).html(tcNo);
}
</script>
</head>
<body style="text-align: center; margin-top: 120px" onload="generateTcNo('tcDiv')">
<div style="font-size: 40px; color: rgb(0, 0, 255);">...TC Kimlik Numarası Üreticisi...</div>
<br /><br />
<button type="button" onclick="generateTcNo('tcDiv');" id="tcButton" style="width: 100px; height: 38px; font-size: 23px">Üret</button>
<br /><br />
<div id="tcDiv" style="font-size:30px;"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment