텍스트 필드에 숫자 입력시 3자리 단위로 , 찍는 소스
<form name= form>
<input class="field" name=money onkeyup="number_format(this)">
</form>
<script language="javascript">
function number_format(f) {
var val = f.value;
var len = val.length;
var number_format1 = "", number_format2 = "";
var c = 0;
if(val.charCodeAt(len-1)<48 || val.charCodeAt(len-1)>57) {
alert("숫자만 입력해주세요");
f.value = val.substr(0, (len-1));
}else{
if(len > 3) {
for(i = 0 ; i < len; i++){
one = val.charAt(i)
if(one != ",") number_format1 += one;
}
var number_format1_len = number_format1.length;
var in_c = number_format1_len%3;
if(!in_c) in_c = 3;
for(i = 0 ; i < number_format1_len; i++){
number_format2_one = number_format1.charAt(i)
if(i == in_c){
number_format2 += ",";
in_c = 3+in_c;
}
number_format2 += number_format2_one;
}
f.value = number_format2;
}
}
}
</script>
댓글 1개
게시판 목록
퍼블리셔팁
질문은 상단의 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 407 | HTML |
|
15년 전 | 2812 | |
| 406 | HTML | 15년 전 | 2322 | ||
| 405 | HTML | 15년 전 | 2701 | ||
| 404 | HTML |
|
15년 전 | 2371 | |
| 403 | HTML | 15년 전 | 2393 | ||
| 402 | HTML |
soulfuleyes
|
15년 전 | 4658 | |
| 401 | HTML | 15년 전 | 3116 | ||
| 400 | HTML | 15년 전 | 2165 | ||
| 399 | HTML | 15년 전 | 2808 | ||
| 398 | HTML | 15년 전 | 2033 | ||
| 397 | HTML | 15년 전 | 2524 | ||
| 396 | HTML | 15년 전 | 2654 | ||
| 395 | HTML | 15년 전 | 3182 | ||
| 394 | HTML |
|
15년 전 | 4244 | |
| 393 | HTML |
원더풀라입
|
15년 전 | 2129 | |
| 392 | HTML |
원더풀라입
|
15년 전 | 2204 | |
| 391 | HTML |
원더풀라입
|
15년 전 | 2276 | |
| 390 | HTML | 15년 전 | 2702 | ||
| 389 | HTML |
gamebomb
|
15년 전 | 2868 | |
| 388 | HTML |
intel
|
15년 전 | 5711 | |
| 387 | HTML | 15년 전 | 5984 | ||
| 386 | HTML | 15년 전 | 3167 | ||
| 385 | HTML | 15년 전 | 3210 | ||
| 384 | HTML | 15년 전 | 5104 | ||
| 383 | HTML | 15년 전 | 3364 | ||
| 382 | HTML |
헐크매니아
|
15년 전 | 3561 | |
| 381 | HTML |
WebRIA
|
15년 전 | 10344 | |
| 380 | HTML |
WebRIA
|
15년 전 | 3686 | |
| 379 | HTML | 15년 전 | 3828 | ||
| 378 | HTML | 16년 전 | 4852 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기