腼腆小青年

身份证号尾数计算器
<script> function calc(str) { /*DO WHAT THE FUCK YO...
扫描右侧二维码阅读全文
29
2019/07

身份证号尾数计算器

<script>
function calc(str)
{

/*
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  1. You just DO WHAT THE FUCK YOU WANT TO.
    */
    var coeff = [7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1];
    var suffix = ['1','0','x','9','8','7','6','5','4','3','2'];
    var sum = 0;
    for(var i=0;i<17;i++)

    sum += coeff[i] * parseInt(str.charCodeAt(i)-48);

    sum %= 11;
    str = str.substr(0,17) + suffix[sum];
    return str;
    }
    <script>
    <button onclick="alert(calc(prompt('请输入待计算的身份证号(前17位)')))" >计算</button>

在线版:http://blog.cxqn.info/archives/1053

Last modification:July 29th, 2019 at 06:59 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment