전화번호 입력시 자동 하이픈 넣기
<script>
function OnCheckPhone(oTa) {
var oForm = oTa.form ;
var sMsg = oTa.value ;
var onlynum = "" ;
onlynum = RemoveDash2(sMsg);
if(event.keyCode != 8 ) {
if (GetMsgLen(onlynum) <= 2) oTa.value = onlynum ;
if (GetMsgLen(onlynum) == 3) oTa.value = onlynum + "-";
if (GetMsgLen(onlynum) == 4) oTa.value = onlynum.substring(0,3) + "-" + onlynum.substring(3,4) ;
if (GetMsgLen(onlynum) == 5) oTa.value = onlynum.substring(0,3) + "-" + onlynum.substring(3,5) ;
if (GetMsgLen(onlynum) == 6) oTa.value = onlynum.substring(0,3) + "-" + onlynum.substring(3,6) ;
if (GetMsgLen(onlynum) == 7) oTa.value = onlynum.substring(0,3) + "-" + onlynum.substring(3,7) ;
if (GetMsgLen(onlynum) == 8) oTa.value = onlynum.substring(0,4) + "-" + onlynum.substring(4,8) ;
if (GetMsgLen(onlynum) == 9) oTa.value = onlynum.substring(0,4) + "-" + onlynum.substring(4,9) ;
}
}
function RemoveDash2(sNo) {
var reNo = ""
for(var i=0; i<sNo.length; i++) {
if ( sNo.charAt(i) != "-" ) {
reNo += sNo.charAt(i)
}
}
return reNo
}
function GetMsgLen(sMsg) { // 0-127 1byte, 128~ 2byte
var count = 0
for(var i=0; i<sMsg.length; i++) {
if ( sMsg.charCodeAt(i) > 127 ) {
count += 2
}
else {
count++
}
}
return count
}
</script>
<form>
<input type=text name=num1 value="011" size=4> -
<input type=text name=num2 onfocus="OnCheckPhone(this)" onKeyup="OnCheckPhone(this)" size=10>
</form>
function OnCheckPhone(oTa) {
var oForm = oTa.form ;
var sMsg = oTa.value ;
var onlynum = "" ;
onlynum = RemoveDash2(sMsg);
if(event.keyCode != 8 ) {
if (GetMsgLen(onlynum) <= 2) oTa.value = onlynum ;
if (GetMsgLen(onlynum) == 3) oTa.value = onlynum + "-";
if (GetMsgLen(onlynum) == 4) oTa.value = onlynum.substring(0,3) + "-" + onlynum.substring(3,4) ;
if (GetMsgLen(onlynum) == 5) oTa.value = onlynum.substring(0,3) + "-" + onlynum.substring(3,5) ;
if (GetMsgLen(onlynum) == 6) oTa.value = onlynum.substring(0,3) + "-" + onlynum.substring(3,6) ;
if (GetMsgLen(onlynum) == 7) oTa.value = onlynum.substring(0,3) + "-" + onlynum.substring(3,7) ;
if (GetMsgLen(onlynum) == 8) oTa.value = onlynum.substring(0,4) + "-" + onlynum.substring(4,8) ;
if (GetMsgLen(onlynum) == 9) oTa.value = onlynum.substring(0,4) + "-" + onlynum.substring(4,9) ;
}
}
function RemoveDash2(sNo) {
var reNo = ""
for(var i=0; i<sNo.length; i++) {
if ( sNo.charAt(i) != "-" ) {
reNo += sNo.charAt(i)
}
}
return reNo
}
function GetMsgLen(sMsg) { // 0-127 1byte, 128~ 2byte
var count = 0
for(var i=0; i<sMsg.length; i++) {
if ( sMsg.charCodeAt(i) > 127 ) {
count += 2
}
else {
count++
}
}
return count
}
</script>
<form>
<input type=text name=num1 value="011" size=4> -
<input type=text name=num2 onfocus="OnCheckPhone(this)" onKeyup="OnCheckPhone(this)" size=10>
</form>
댓글 1개
쉽다zzz
12년 전
감사요~
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5430 | 13년 전 | 1444 | ||
| 5429 |
phpman
|
13년 전 | 860 | |
| 5428 | 13년 전 | 1257 | ||
| 5427 |
phpman
|
13년 전 | 852 | |
| 5426 |
PHPㅡASP프로그래머
|
13년 전 | 1089 | |
| 5425 | 13년 전 | 794 | ||
| 5424 | 13년 전 | 738 | ||
| 5423 | 13년 전 | 734 | ||
| 5422 | 13년 전 | 1836 | ||
| 5421 |
PHPㅡASP프로그래머
|
13년 전 | 810 | |
| 5420 |
|
13년 전 | 1635 | |
| 5419 | 13년 전 | 820 | ||
| 5418 | 13년 전 | 710 | ||
| 5417 | 13년 전 | 625 | ||
| 5416 | 13년 전 | 992 | ||
| 5415 | 13년 전 | 790 | ||
| 5414 | 13년 전 | 726 | ||
| 5413 | 13년 전 | 790 | ||
| 5412 | 13년 전 | 1355 | ||
| 5411 | 13년 전 | 864 | ||
| 5410 | 13년 전 | 1270 | ||
| 5409 | 13년 전 | 4251 | ||
| 5408 | 13년 전 | 987 | ||
| 5407 |
ckflower
|
13년 전 | 2426 | |
| 5406 |
ddokkani
|
13년 전 | 1379 | |
| 5405 | 13년 전 | 1593 | ||
| 5404 | 13년 전 | 664 | ||
| 5403 | 13년 전 | 697 | ||
| 5402 |
밤거리빵빵
|
13년 전 | 6023 | |
| 5401 |
PHPㅡASP프로그래머
|
13년 전 | 977 | |
| 5400 |
|
13년 전 | 1192 | |
| 5399 | 13년 전 | 4992 | ||
| 5398 |
부산아무개
|
13년 전 | 1647 | |
| 5397 | 13년 전 | 2451 | ||
| 5396 | 13년 전 | 1847 | ||
| 5395 | 13년 전 | 1052 | ||
| 5394 | 13년 전 | 1127 | ||
| 5393 | 13년 전 | 1043 | ||
| 5392 |
아르toria
|
13년 전 | 761 | |
| 5391 |
|
13년 전 | 1145 | |
| 5390 |
디지털홍익인간
|
13년 전 | 7704 | |
| 5389 | 13년 전 | 3110 | ||
| 5388 | 13년 전 | 872 | ||
| 5387 |
WaaNee
|
13년 전 | 1909 | |
| 5386 | 13년 전 | 2104 | ||
| 5385 | 13년 전 | 4624 | ||
| 5384 | 13년 전 | 936 | ||
| 5383 | 13년 전 | 2131 | ||
| 5382 | 13년 전 | 664 | ||
| 5381 |
JacobJeon
|
13년 전 | 1085 | |
| 5380 | 13년 전 | 1137 | ||
| 5379 | 13년 전 | 686 | ||
| 5378 | 13년 전 | 10467 | ||
| 5377 | 13년 전 | 862 | ||
| 5376 | 13년 전 | 1460 | ||
| 5375 | 13년 전 | 838 | ||
| 5374 | 13년 전 | 847 | ||
| 5373 | 13년 전 | 2066 | ||
| 5372 | 13년 전 | 1695 | ||
| 5371 |
|
13년 전 | 1639 | |
| 5370 | 13년 전 | 2907 | ||
| 5369 |
아자12345
|
13년 전 | 1014 | |
| 5368 | 13년 전 | 707 | ||
| 5367 | 13년 전 | 1085 | ||
| 5366 | 13년 전 | 2152 | ||
| 5365 | 13년 전 | 1569 | ||
| 5364 | 13년 전 | 1095 | ||
| 5363 |
|
13년 전 | 1356 | |
| 5362 | 13년 전 | 818 | ||
| 5361 | 13년 전 | 1353 | ||
| 5360 | 13년 전 | 711 | ||
| 5359 | 13년 전 | 1370 | ||
| 5358 | 13년 전 | 1199 | ||
| 5357 | 13년 전 | 1599 | ||
| 5356 | 13년 전 | 1099 | ||
| 5355 |
techer
|
13년 전 | 1352 | |
| 5354 |
|
13년 전 | 1012 | |
| 5353 | 13년 전 | 743 | ||
| 5352 | 13년 전 | 824 | ||
| 5351 | 13년 전 | 1204 | ||
| 5350 | 13년 전 | 742 | ||
| 5349 |
|
13년 전 | 1444 | |
| 5348 | 13년 전 | 854 | ||
| 5347 | 13년 전 | 759 | ||
| 5346 | 13년 전 | 875 | ||
| 5345 | 13년 전 | 816 | ||
| 5344 |
후라보노보노
|
13년 전 | 1960 | |
| 5343 | 13년 전 | 1159 | ||
| 5342 | 13년 전 | 1125 | ||
| 5341 | 13년 전 | 2076 | ||
| 5340 |
|
13년 전 | 1119 | |
| 5339 |
AMDbest
|
13년 전 | 740 | |
| 5338 | 13년 전 | 737 | ||
| 5337 |
프로프리랜서
|
13년 전 | 1480 | |
| 5336 |
프로프리랜서
|
13년 전 | 924 | |
| 5335 | 13년 전 | 722 | ||
| 5334 |
|
13년 전 | 974 | |
| 5333 | 13년 전 | 2838 | ||
| 5332 | 13년 전 | 1519 | ||
| 5331 | 13년 전 | 1323 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기