htmlhead /headbody input type="text" size="40" id="inid" / button onclick="idConfirm(inid)"aaa/button/body/html script type="text/javascript" function idConfirm(idTag){ var idCard=document.getElementById("inid").value; var ratioA=new Array(
<html> <head> </head> <body> <input type="text" size="40" id="inid" /> <button onclick="idConfirm(inid)">aaa</button> </body> </html> <script type="text/javascript"> function idConfirm(idTag){ var idCard=document.getElementById("inid").value; var ratioA=new Array(7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2); var comfirm="10x98765432"; var sum=0; var avg=0; var k=0; if(idCard.length===18){ for(i=0;i<17;i++){ k=parseInt(idCard.charAt(i))*ratioA[i]; sum+=k; } avg=sum%11; idCard.charAt(17)==comfirm.charAt(avg) ? alert("true") : alert("false"); } } </script>