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,158
17년 전 조회 1,855
17년 전 조회 2,152
17년 전 조회 2,965
17년 전 조회 1,242
17년 전 조회 1,332
17년 전 조회 1,557
17년 전 조회 1,227
17년 전 조회 4,358
17년 전 조회 3,901
17년 전 조회 2,789
17년 전 조회 1,593
17년 전 조회 1,337
17년 전 조회 1,606
17년 전 조회 2,522
17년 전 조회 1,737
17년 전 조회 2,021
17년 전 조회 1,309
17년 전 조회 1,041
17년 전 조회 1,125
17년 전 조회 2,926
17년 전 조회 2,461
17년 전 조회 2,046
17년 전 조회 2,044
17년 전 조회 1,799
17년 전 조회 2,242
17년 전 조회 2,016
17년 전 조회 1,989
17년 전 조회 1,877
17년 전 조회 1,212
17년 전 조회 1,829
17년 전 조회 2,232
17년 전 조회 2,304
17년 전 조회 1,643
17년 전 조회 1,510
17년 전 조회 1,361
17년 전 조회 2,577
17년 전 조회 2,675
17년 전 조회 2,068
17년 전 조회 2,417
17년 전 조회 2,722
17년 전 조회 1,325
17년 전 조회 1,192
17년 전 조회 6,325
17년 전 조회 1,178
17년 전 조회 1,626
17년 전 조회 1,778
17년 전 조회 1,101
17년 전 조회 1,192
17년 전 조회 1,894
17년 전 조회 1,523
17년 전 조회 3,620
17년 전 조회 1,207
17년 전 조회 1,912
17년 전 조회 1,168
17년 전 조회 1,384
17년 전 조회 2,361
17년 전 조회 2,015
17년 전 조회 1,038
17년 전 조회 1,038
17년 전 조회 1,092
17년 전 조회 6,047
17년 전 조회 5,852
17년 전 조회 2,028
17년 전 조회 1,024
17년 전 조회 1,121
17년 전 조회 2,084
17년 전 조회 1,513
17년 전 조회 1,158
17년 전 조회 1,188
17년 전 조회 1,129
17년 전 조회 1,044
17년 전 조회 3,961
17년 전 조회 2,170
17년 전 조회 1,620
17년 전 조회 2,767
17년 전 조회 1,471
17년 전 조회 1,154
17년 전 조회 1,175
17년 전 조회 1,244
17년 전 조회 1,131
17년 전 조회 1,245
17년 전 조회 2,400
17년 전 조회 4,187
17년 전 조회 1,190
17년 전 조회 3,950
17년 전 조회 4,098
17년 전 조회 1,213
17년 전 조회 2,179
17년 전 조회 1,622
17년 전 조회 3,215
17년 전 조회 1,357
17년 전 조회 3,599
17년 전 조회 3,391
17년 전 조회 2,564
17년 전 조회 2,938
17년 전 조회 2,627
17년 전 조회 1,943
17년 전 조회 3,313
17년 전 조회 2,624
🐛 버그신고