마지막 숫자의 정확성은 ID 번호에 따라 계산됩니다. 잘못된 경우 올바른 결과가 나옵니다. 프로그램을 깨는 것은 매우 흥미 롭습니다.
<! doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w.w.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><Html xmlns = "http://www.w3.org/1999/xhtml"> <head> <head> <meta http-equiv = "content-type"content = "text/html; charset = utf-8"/<title> javascript 18-digit id number </head> </head> </head> {var arr = id.split ( ''), sum = 0, vc = [7, 9, 10, 5, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]; for (var i = 0; i <17; i ++) sum+= vc [i] * parseint (arr [i]); 반환 [ '1', '0', 'x', '9', '8', '7', '6', '5', '4', '3', '2'] [Sum % 11]; } function validId (id) {if (/^/d {18 }$/.test (id)) {var c = id.charat (17), rc = getIdchar18 (id); if (c == rc) showrst ( '입력 한 18 자리 ID 번호는 정확합니다! <br> 생일 :' + id.substr (6, 8) + '<br> 성별 :' + [ '여성', '남성'] [parseint (16)) % 2]); else showrst ( '입력 한 18 자리 ID 번호는 올바르지 않으며 18 자리 확인 코드는' + rc + '!'); } else showrst ( 'ID 번호의 18 자리 ID 번호를 입력하십시오!'); } function showrst ( 'msg) {document.getElementById ('rst '). innerHtml = msg} </script> <입력 유형 = "text"onblur = "validId (this.value)"/> <div id = "rst"> </div> </body> </html>