주민번호, 외국인번호 검사 스크립트
// 내국인
function ssnCheck(ssn) {
var lastid, li_mod, li_minus, li_last;
var checkValue = 0;
if (ssn.length != 13) return false;
lastid = parseFloat(ssn.substring(12,13));
checkValue += (parseInt(ssn.substring(0,1)) * 2) + (parseInt(ssn.substring(1,2)) * 3)
+ (parseInt(ssn.substring(2,3)) * 4) + (parseInt(ssn.substring(3,4)) * 5)
+ (parseInt(ssn.substring(4,5)) * 6) + (parseInt(ssn.substring(5,6)) * 7)
+ (parseInt(ssn.substring(6,7)) * 8) + (parseInt(ssn.substring(7,8)) * 9)
+ (+parseInt(ssn.substring(8,9)) * 2) + (parseInt(ssn.substring(9,10)) * 3)
+ (parseInt(ssn.substring(10,11)) * 4) + (parseInt(ssn.substring(11,12)) * 5);
li_mod = checkValue % 11;
li_minus = 11 - li_mod;
li_last = li_minus % 10;
if (li_last != lastid) return false;
return true;
}
// 외국인
function isFrgNo(fgnno) {
var sum = 0;
var odd = 0;
buf = new Array(13);
for(i=0; i<13; i++) buf[i] = parseInt(fgnno.charAt(i));
odd = buf[7]*10 + buf[8];
if(odd%2 != 0) return false;
if((buf[11]!=6) && (buf[11]!=7) && (buf[11]!=8) && (buf[11]!=9)) return false;
multipliers = [2,3,4,5,6,7,8,9,2,3,4,5];
for(i=0, sum=0; i<12; i++) sum += (buf[i] *= multipliers[i]);
sum = 11 - (sum%11);
if(sum >= 10) sum -= 10;
sum += 2;
if(sum >= 10) sum -= 10;
if(sum != buf[12]) return false;
return true;
}
<script>
function number_check(){
var f = document.frm;
var ssn1 = f.jumin1.value;
var ssn2 = f.jumin2.value;
var ssn = ssn1 + ssn2;
if(ssn2.substring(0,1) == '1' || ssn2.substring(0,1) == '3' ||
ssn2.substring(0,1) == '2' || ssn2.substring(0,1) == '4') {
// 국내 주민번호 체크
if (ssnCheck(ssn) == false ) {
alert('주민번호를 정확히 입력하십시오.');
f.jumin1.value = '';
f.jumin2.value = '';
f.jumin1.focus();
return;
}
} else {
// 외국인 등록번호 체크
if(isFrgNo(ssn) == false) {
alert( "외국인 등록번호를 정확히 입력하십시오." );
f.jumin1.value = '';
f.jumin2.value = '';
f.jumin1.focus();
return;
}
}
}
</script>}
<form name="frm" onsubmit="return false;">
<input type="text" name="jumin1"> - <input type="password" name="jumin2"> <button onclick="number_check()">체크</button>
</form>
댓글 2개
LSS벤처스
12년 전
좋네요.
12년 전
필요할때 헤매는 소스 감사합니다.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5730 | 13년 전 | 766 | ||
| 5729 | 13년 전 | 3586 | ||
| 5728 | 13년 전 | 1150 | ||
| 5727 |
freejazzme
|
13년 전 | 1111 | |
| 5726 | 13년 전 | 1448 | ||
| 5725 |
itlang
|
13년 전 | 427 | |
| 5724 | 13년 전 | 504 | ||
| 5723 |
crocojea
|
13년 전 | 1481 | |
| 5722 | 13년 전 | 1977 | ||
| 5721 | 13년 전 | 711 | ||
| 5720 |
쿠우우우우
|
13년 전 | 470 | |
| 5719 | 13년 전 | 606 | ||
| 5718 |
|
13년 전 | 586 | |
| 5717 | 13년 전 | 1444 | ||
| 5716 |
|
13년 전 | 1035 | |
| 5715 | 13년 전 | 468 | ||
| 5714 | 13년 전 | 472 | ||
| 5713 | 13년 전 | 537 | ||
| 5712 |
|
13년 전 | 775 | |
| 5711 | 13년 전 | 697 | ||
| 5710 |
minini
|
13년 전 | 489 | |
| 5709 |
|
13년 전 | 1331 | |
| 5708 | 13년 전 | 678 | ||
| 5707 | 13년 전 | 5857 | ||
| 5706 |
오니기리죠
|
13년 전 | 1019 | |
| 5705 |
HSEngine
|
13년 전 | 657 | |
| 5704 |
Giggle
|
13년 전 | 1695 | |
| 5703 | 13년 전 | 504 | ||
| 5702 |
AMDbest
|
13년 전 | 1421 | |
| 5701 |
|
13년 전 | 2888 | |
| 5700 | 13년 전 | 500 | ||
| 5699 |
미션임파썩을
|
13년 전 | 540 | |
| 5698 | 13년 전 | 625 | ||
| 5697 | 13년 전 | 532 | ||
| 5696 | 13년 전 | 433 | ||
| 5695 |
|
13년 전 | 696 | |
| 5694 | 13년 전 | 439 | ||
| 5693 | 13년 전 | 977 | ||
| 5692 | 13년 전 | 949 | ||
| 5691 |
쉽다zzz
|
13년 전 | 718 | |
| 5690 | 13년 전 | 474 | ||
| 5689 | 13년 전 | 632 | ||
| 5688 | 13년 전 | 1412 | ||
| 5687 | 13년 전 | 467 | ||
| 5686 | 13년 전 | 2448 | ||
| 5685 |
AMDbest
|
13년 전 | 2158 | |
| 5684 | 13년 전 | 2038 | ||
| 5683 | 13년 전 | 1352 | ||
| 5682 |
AMDbest
|
13년 전 | 666 | |
| 5681 | 13년 전 | 3799 | ||
| 5680 |
|
13년 전 | 1682 | |
| 5679 | 13년 전 | 2087 | ||
| 5678 |
|
13년 전 | 510 | |
| 5677 |
mobiler
|
13년 전 | 463 | |
| 5676 | 13년 전 | 1600 | ||
| 5675 | 13년 전 | 584 | ||
| 5674 |
PHPㅡASP프로그래머
|
13년 전 | 1811 | |
| 5673 |
PHPㅡASP프로그래머
|
13년 전 | 1487 | |
| 5672 |
PHPㅡASP프로그래머
|
13년 전 | 1277 | |
| 5671 |
PHPㅡASP프로그래머
|
13년 전 | 1211 | |
| 5670 |
PHPㅡASP프로그래머
|
13년 전 | 4607 | |
| 5669 | 13년 전 | 3050 | ||
| 5668 | 13년 전 | 1411 | ||
| 5667 | 13년 전 | 490 | ||
| 5666 | 13년 전 | 1142 | ||
| 5665 |
Darby
|
13년 전 | 1601 | |
| 5664 | 13년 전 | 1338 | ||
| 5663 | 13년 전 | 1122 | ||
| 5662 | 13년 전 | 784 | ||
| 5661 | 13년 전 | 449 | ||
| 5660 | 13년 전 | 841 | ||
| 5659 | 13년 전 | 710 | ||
| 5658 | 13년 전 | 531 | ||
| 5657 | 13년 전 | 536 | ||
| 5656 | 13년 전 | 990 | ||
| 5655 | 13년 전 | 437 | ||
| 5654 | 13년 전 | 390 | ||
| 5653 |
졸린다젠장
|
13년 전 | 477 | |
| 5652 |
|
13년 전 | 395 | |
| 5651 | 13년 전 | 1027 | ||
| 5650 | 13년 전 | 718 | ||
| 5649 | 13년 전 | 2230 | ||
| 5648 | 13년 전 | 479 | ||
| 5647 | 13년 전 | 757 | ||
| 5646 | 13년 전 | 1493 | ||
| 5645 | 13년 전 | 679 | ||
| 5644 | 13년 전 | 614 | ||
| 5643 |
|
13년 전 | 573 | |
| 5642 |
쿠마하우스
|
13년 전 | 685 | |
| 5641 |
goaway
|
13년 전 | 1084 | |
| 5640 |
쿠마하우스
|
13년 전 | 647 | |
| 5639 | 13년 전 | 674 | ||
| 5638 |
쿠마하우스
|
13년 전 | 988 | |
| 5637 | 13년 전 | 803 | ||
| 5636 | 13년 전 | 1410 | ||
| 5635 |
goaway
|
13년 전 | 909 | |
| 5634 |
lllolll
|
13년 전 | 414 | |
| 5633 | 13년 전 | 962 | ||
| 5632 | 13년 전 | 4272 | ||
| 5631 | 13년 전 | 564 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기