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,166
17년 전 조회 1,869
17년 전 조회 2,162
17년 전 조회 2,979
17년 전 조회 1,254
17년 전 조회 1,345
17년 전 조회 1,572
17년 전 조회 1,234
17년 전 조회 4,371
17년 전 조회 3,913
17년 전 조회 2,803
17년 전 조회 1,604
17년 전 조회 1,349
17년 전 조회 1,617
17년 전 조회 2,533
17년 전 조회 1,746
17년 전 조회 2,034
17년 전 조회 1,324
17년 전 조회 1,054
17년 전 조회 1,137
17년 전 조회 2,936
17년 전 조회 2,474
17년 전 조회 2,053
17년 전 조회 2,055
17년 전 조회 1,810
17년 전 조회 2,255
17년 전 조회 2,026
17년 전 조회 1,998
17년 전 조회 1,887
17년 전 조회 1,221
17년 전 조회 1,839
17년 전 조회 2,242
17년 전 조회 2,318
17년 전 조회 1,655
17년 전 조회 1,519
17년 전 조회 1,373
17년 전 조회 2,591
17년 전 조회 2,685
17년 전 조회 2,078
17년 전 조회 2,431
17년 전 조회 2,734
17년 전 조회 1,337
17년 전 조회 1,199
17년 전 조회 6,341
17년 전 조회 1,187
17년 전 조회 1,638
17년 전 조회 1,786
17년 전 조회 1,113
17년 전 조회 1,202
17년 전 조회 1,903
17년 전 조회 1,533
17년 전 조회 3,635
17년 전 조회 1,218
17년 전 조회 1,923
17년 전 조회 1,179
17년 전 조회 1,396
17년 전 조회 2,371
17년 전 조회 2,025
17년 전 조회 1,049
17년 전 조회 1,053
17년 전 조회 1,101
17년 전 조회 6,052
17년 전 조회 5,861
17년 전 조회 2,042
17년 전 조회 1,035
17년 전 조회 1,132
17년 전 조회 2,092
17년 전 조회 1,525
17년 전 조회 1,170
17년 전 조회 1,197
17년 전 조회 1,137
17년 전 조회 1,057
17년 전 조회 3,970
17년 전 조회 2,177
17년 전 조회 1,630
17년 전 조회 2,775
17년 전 조회 1,483
17년 전 조회 1,165
17년 전 조회 1,187
17년 전 조회 1,255
17년 전 조회 1,144
17년 전 조회 1,255
17년 전 조회 2,411
17년 전 조회 4,204
17년 전 조회 1,202
17년 전 조회 3,957
17년 전 조회 4,112
17년 전 조회 1,224
17년 전 조회 2,190
17년 전 조회 1,632
17년 전 조회 3,226
17년 전 조회 1,366
17년 전 조회 3,610
17년 전 조회 3,403
17년 전 조회 2,574
17년 전 조회 2,943
17년 전 조회 2,638
17년 전 조회 1,953
17년 전 조회 3,326
17년 전 조회 2,635
🐛 버그신고