[code]
<input type="text" id="price" onkeyup="inputNumberFormat(this)"/>
<script>
function inputNumberFormat(obj) {
obj.value = comma(uncomma(obj.value));
}
function comma(str) {
str = String(str);
return str.replace(/(\d)(?=(?:\d{3})+(?!\d))/g, '$1,');
}
function uncomma(str) {
str = String(str);
return str.replace(/[^\d]+/g, '');
}
</script>
[/code]
의외로 물어보시는 분들이 많으신데 팁게에 없어서 적습니다~
ps
return 줄바꿈이 왜 되어있는지 모르겠네요 ㅠㅠ
수정했습니다! 불편을드려 죄송해요~~
댓글 10개
게시글 목록
| 번호 | 제목 |
|---|---|
| 19430 | |
| 19420 | |
| 19398 | |
| 19387 | |
| 19379 | |
| 19371 | |
| 19358 | |
| 19354 | |
| 19345 | |
| 19343 | |
| 19330 | |
| 19322 | |
| 19303 | |
| 19296 | |
| 19283 | |
| 19274 | |
| 19256 | |
| 19244 | |
| 19238 | |
| 19230 | |
| 19229 | |
| 19219 | |
| 19201 | |
| 19184 | |
| 19183 | |
| 19177 | |
| 19153 | |
| 19133 | |
| 19132 | |
| 19090 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기