Die Richtigkeit der letzten Ziffer wird basierend auf der ID -Nummer berechnet. Wenn es falsch ist, wird das richtige Ergebnis angegeben. Es ist sehr interessant, das Programm zu brechen.
<! DocType html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transsitional.dtd"><Htmlmlml xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv = "content-type" content = "text/html; Charset = utf-8"/> <title> JavaScript 18-Digit ID-Nr. Last Digit Verification Code </title> </head> </head> </head> </head> </head> </head> </head> </head> </head> </head> </head> </head> </head> <- {var arr = id.split (''), sum = 0, vc = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]; für (var i = 0; i <17; i ++) sum+= vc [i] * parsesint (arr [i]); return ['1', '0', 'x', '9', '8', '7', '6', '5', '4', '3', '2'] [sum % 11]; } function ValidID (id) {if (/^/dery8}$/.test(id)) {var c = id.charat (17), rc = getIdchar18 (id); if (c == rc) showrst ('Die 18-stellige ID-Nummer, die Sie eingegeben haben, ist korrekt! sonst Showrst ('Die 18-stellige ID-Nummer, die Sie eingegeben haben, ist falsch, der 18-stellige Überprüfungscode sollte' + RC + '!') sein; } else showrst ('Bitte geben Sie die 18-stellige ID-Nummer für ID-Nummer ein!'); } function Showrst ('msg) {document.getElementById (' RST '). InnerHtml = msg} </script> <Eingabe type = "text" onblur = "validId (this.value)"/> <divid id = "rst"> </div> </body> </html>> <divid id = "