전화번호 입력시 자동 하이픈 넣기
<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년 전
감사요~
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 230 | 20년 전 | 2036 | ||
| 229 | 20년 전 | 3131 | ||
| 228 | 20년 전 | 3322 | ||
| 227 | 20년 전 | 2383 | ||
| 226 | 20년 전 | 5458 | ||
| 225 | 20년 전 | 2506 | ||
| 224 | 20년 전 | 2950 | ||
| 223 | 20년 전 | 4195 | ||
| 222 | 20년 전 | 2594 | ||
| 221 | 20년 전 | 2277 | ||
| 220 | 20년 전 | 3665 | ||
| 219 | 20년 전 | 2062 | ||
| 218 | 20년 전 | 3550 | ||
| 217 | 20년 전 | 2467 | ||
| 216 | 20년 전 | 2894 | ||
| 215 | 20년 전 | 2201 | ||
| 214 | 20년 전 | 3324 | ||
| 213 | 20년 전 | 2909 | ||
| 212 | 20년 전 | 3038 | ||
| 211 | 20년 전 | 2136 | ||
| 210 | 20년 전 | 1865 | ||
| 209 | 20년 전 | 2330 | ||
| 208 | 20년 전 | 1961 | ||
| 207 | 20년 전 | 1661 | ||
| 206 | 20년 전 | 1848 | ||
| 205 | 20년 전 | 3936 | ||
| 204 | 20년 전 | 1666 | ||
| 203 | 20년 전 | 1999 | ||
| 202 | 20년 전 | 2338 | ||
| 201 | 20년 전 | 1813 | ||
| 200 | 20년 전 | 2942 | ||
| 199 | 20년 전 | 1997 | ||
| 198 | 20년 전 | 2077 | ||
| 197 | 20년 전 | 3641 | ||
| 196 | 20년 전 | 2960 | ||
| 195 | 20년 전 | 2083 | ||
| 194 | 20년 전 | 10227 | ||
| 193 | 20년 전 | 2235 | ||
| 192 | 20년 전 | 1578 | ||
| 191 | 20년 전 | 2648 | ||
| 190 | 20년 전 | 2280 | ||
| 189 | 20년 전 | 1670 | ||
| 188 | 20년 전 | 1463 | ||
| 187 | 20년 전 | 1892 | ||
| 186 | 20년 전 | 1691 | ||
| 185 | 20년 전 | 1725 | ||
| 184 | 20년 전 | 2326 | ||
| 183 | 20년 전 | 1537 | ||
| 182 | 20년 전 | 1473 | ||
| 181 | 20년 전 | 1612 | ||
| 180 | 20년 전 | 2707 | ||
| 179 | 20년 전 | 1786 | ||
| 178 | 20년 전 | 1841 | ||
| 177 | 20년 전 | 1967 | ||
| 176 | 20년 전 | 1790 | ||
| 175 | 20년 전 | 1862 | ||
| 174 | 20년 전 | 1684 | ||
| 173 | 20년 전 | 2051 | ||
| 172 | 20년 전 | 1771 | ||
| 171 | 20년 전 | 2549 | ||
| 170 | 20년 전 | 2255 | ||
| 169 | 20년 전 | 2535 | ||
| 168 | 20년 전 | 1464 | ||
| 167 | 20년 전 | 1563 | ||
| 166 | 20년 전 | 2136 | ||
| 165 | 20년 전 | 1600 | ||
| 164 | 20년 전 | 3745 | ||
| 163 | 20년 전 | 2634 | ||
| 162 | 20년 전 | 2062 | ||
| 161 | 20년 전 | 2764 | ||
| 160 | 20년 전 | 1713 | ||
| 159 | 20년 전 | 1589 | ||
| 158 | 20년 전 | 2542 | ||
| 157 | 20년 전 | 1468 | ||
| 156 | 20년 전 | 1711 | ||
| 155 | 20년 전 | 3218 | ||
| 154 | 20년 전 | 1871 | ||
| 153 | 20년 전 | 1603 | ||
| 152 | 20년 전 | 4929 | ||
| 151 | 20년 전 | 4559 | ||
| 150 | 20년 전 | 3498 | ||
| 149 | 20년 전 | 3770 | ||
| 148 | 20년 전 | 7048 | ||
| 147 | 20년 전 | 3532 | ||
| 146 | 20년 전 | 2598 | ||
| 145 | 20년 전 | 2597 | ||
| 144 | 20년 전 | 7155 | ||
| 143 | 20년 전 | 4575 | ||
| 142 | 20년 전 | 1885 | ||
| 141 | 20년 전 | 3242 | ||
| 140 | 20년 전 | 1940 | ||
| 139 | 20년 전 | 1534 | ||
| 138 | 20년 전 | 2283 | ||
| 137 | 20년 전 | 1765 | ||
| 136 | 20년 전 | 1440 | ||
| 135 | 20년 전 | 1777 | ||
| 134 | 20년 전 | 2952 | ||
| 133 | 20년 전 | 2427 | ||
| 132 | 20년 전 | 1701 | ||
| 131 | 20년 전 | 1629 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기