텍스트 필드에 숫자 입력시 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에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 257 | HTML | 18년 전 | 3678 | ||
| 256 | HTML | 18년 전 | 3399 | ||
| 255 | HTML |
hsp1980
|
18년 전 | 3795 | |
| 254 | HTML |
mixdesign
|
18년 전 | 6143 | |
| 253 | HTML | 18년 전 | 4251 | ||
| 252 | HTML |
hsp1980
|
18년 전 | 4630 | |
| 251 | 기타 |
|
18년 전 | 7214 | |
| 250 | HTML |
mixdesign
|
18년 전 | 3635 | |
| 249 | HTML |
mixdesign
|
18년 전 | 3232 | |
| 248 | HTML |
mixdesign
|
18년 전 | 4995 | |
| 247 | HTML | 18년 전 | 3637 | ||
| 246 | HTML | 18년 전 | 5309 | ||
| 245 | HTML | 18년 전 | 6421 | ||
| 244 | HTML | 18년 전 | 7561 | ||
| 243 | HTML | 18년 전 | 3462 | ||
| 242 | HTML | 18년 전 | 4188 | ||
| 241 | HTML | 18년 전 | 9649 | ||
| 240 | HTML |
frotone
|
18년 전 | 5144 | |
| 239 | HTML | 18년 전 | 11352 | ||
| 238 | HTML |
mixdesign
|
18년 전 | 5223 | |
| 237 | HTML |
mixdesign
|
18년 전 | 3285 | |
| 236 | HTML |
|
18년 전 | 4494 | |
| 235 | HTML |
mixdesign
|
18년 전 | 3082 | |
| 234 | HTML | 18년 전 | 5187 | ||
| 233 | HTML | 18년 전 | 3598 | ||
| 232 | HTML | 18년 전 | 3116 | ||
| 231 | HTML | 18년 전 | 4097 | ||
| 230 | HTML | 18년 전 | 5357 | ||
| 229 | HTML | 18년 전 | 5597 | ||
| 228 | HTML | 18년 전 | 3246 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기