Created
February 6, 2021 14:01
thai national id generator
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
<script type="text/javascript"> | |
var d1 = Math.floor(Math.random() * 10); | |
var d2 = Math.floor(Math.random() * 10); | |
var d3 = Math.floor(Math.random() * 10); | |
var d4 = Math.floor(Math.random() * 10); | |
var d5 = Math.floor(Math.random() * 10); | |
var d6 = Math.floor(Math.random() * 10); | |
var d7 = Math.floor(Math.random() * 10); | |
var d8 = Math.floor(Math.random() * 10); | |
var d9 = Math.floor(Math.random() * 10); | |
var d10 = Math.floor(Math.random() * 10); | |
var d11 = Math.floor(Math.random() * 10); | |
var d12 = Math.floor(Math.random() * 10); | |
var n13 = 11 - (((d1 * 13) + (d2 * 12) + (d3 * 11) + (d4 * 10) + (d5 * 9) + (d6 * 8) + (d7 * 7) + (d8 * 6) + (d9 * 5) + (d10 * 4) + (d11 * 3) + (d12 * 2)) % 11); | |
if (n13 == 10) { | |
var d13 = 0; | |
} else if (n13 == 11) { | |
var d13 = 1; | |
} else { | |
var d13 = n13; | |
} | |
document.write(d1); | |
document.write(d2); | |
document.write(d3); | |
document.write(d4); | |
document.write(d5); | |
document.write(d6); | |
document.write(d7); | |
document.write(d8); | |
document.write(d9); | |
document.write(d10); | |
document.write(d11); | |
document.write(d12); | |
document.write(d13); | |
document.write('<br> หรือ <br>'); | |
document.write(d1 + "-"); | |
document.write(d2); | |
document.write(d3); | |
document.write(d4); | |
document.write(d5 + "-"); | |
document.write(d6); | |
document.write(d7); | |
document.write(d8); | |
document.write(d9); | |
document.write(d10 + "-"); | |
document.write(d11); | |
document.write(d12 + "-"); | |
document.write(d13); | |
document.write('<form><input type=button value="สุ่ม" onClick="history.go()"></form>') | |
</script> | |
/** from https://lertsirikarn.blogspot.com/p/thai-id-number-generator.html */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment