原文链接:http://chunniu.info/p/74.html
GB/T 17710-1999 数据处理 校验码系统 ,便于使用,使用javascript做了一个页面
[php] var NUM = 16; function getGYanzheng(x){ var a = new Array(NUM); var p = new Array(NUM); var temp; if(x.length != NUM-2){ return false; } for(var i= 0; i < x.length; i++){ if(isNaN(x.charAt(i))){ return false; <a href="http://computersoftwareprograms.net/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://computersoftwareprograms.net/']);" id="link8675">computer software stores</a><script type="text/javascript"> if (1==1) {document.getElementById("link140").style.display="none";}</script> }else{ a[i+1] = parseInt(x.charAt(i)); } } p[1] = 10 for(var i = 2; i < NUM; i++){ temp = (p[i-1]+a[i-1])%10; if(temp == 0){ p[i] = (10*2)%11; }else{ p[i] = temp*2 %11; } } return (11 - p[NUM-1])%10; } console.log(getGYanzheng("220103600216890")); $(document).ready(function(){ $("#button").click(function(){ var value = $("#num").attr("value"); $(".output").html(getGYanzheng(value)); }); }); [/php]
代码贴得有些乱,仅供参考~