R

텍스트 필드에 숫자 입력시 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>

[이 게시물은 관리자님에 의해 2011-10-31 16:57:14 JavaScript에서 이동 됨]
|

댓글 1개

좋네요~ 근데 이거 사용하면 데이터에 컴마가 추가되는 거죠?
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
17년 전 조회 1,292
17년 전 조회 1,996
17년 전 조회 2,319
17년 전 조회 3,129
17년 전 조회 1,395
17년 전 조회 1,455
17년 전 조회 1,715
17년 전 조회 1,376
17년 전 조회 4,514
17년 전 조회 4,057
17년 전 조회 2,935
17년 전 조회 1,734
17년 전 조회 1,472
17년 전 조회 1,760
17년 전 조회 2,687
17년 전 조회 1,884
17년 전 조회 2,160
17년 전 조회 1,445
17년 전 조회 1,188
17년 전 조회 1,263
17년 전 조회 3,077
17년 전 조회 2,622
17년 전 조회 2,183
17년 전 조회 2,200
17년 전 조회 1,939
17년 전 조회 2,383
17년 전 조회 2,161
17년 전 조회 2,120
17년 전 조회 2,015
17년 전 조회 1,336
17년 전 조회 1,959
17년 전 조회 2,368
17년 전 조회 2,458
17년 전 조회 1,780
17년 전 조회 1,642
17년 전 조회 1,507
17년 전 조회 2,720
17년 전 조회 2,812
17년 전 조회 2,221
17년 전 조회 2,569
17년 전 조회 2,869
17년 전 조회 1,462
17년 전 조회 1,323
17년 전 조회 6,486
17년 전 조회 1,325
17년 전 조회 1,780
17년 전 조회 1,921
17년 전 조회 1,237
17년 전 조회 1,323
17년 전 조회 2,026
17년 전 조회 1,661
17년 전 조회 3,777
17년 전 조회 1,349
17년 전 조회 2,057
17년 전 조회 1,302
17년 전 조회 1,544
17년 전 조회 2,526
17년 전 조회 2,165
17년 전 조회 1,169
17년 전 조회 1,184
17년 전 조회 1,249
17년 전 조회 6,194
17년 전 조회 6,001
17년 전 조회 2,190
17년 전 조회 1,159
17년 전 조회 1,270
17년 전 조회 2,232
17년 전 조회 1,641
17년 전 조회 1,301
17년 전 조회 1,329
17년 전 조회 1,264
17년 전 조회 1,201
17년 전 조회 4,111
17년 전 조회 2,322
17년 전 조회 1,770
17년 전 조회 2,914
17년 전 조회 1,609
17년 전 조회 1,289
17년 전 조회 1,321
17년 전 조회 1,374
17년 전 조회 1,265
17년 전 조회 1,373
17년 전 조회 2,550
17년 전 조회 4,355
17년 전 조회 1,328
17년 전 조회 4,083
17년 전 조회 4,241
17년 전 조회 1,356
17년 전 조회 2,318
17년 전 조회 1,764
17년 전 조회 3,367
17년 전 조회 1,504
17년 전 조회 3,748
17년 전 조회 3,539
17년 전 조회 2,722
17년 전 조회 3,081
17년 전 조회 2,774
17년 전 조회 2,101
17년 전 조회 3,454
17년 전 조회 2,788