[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개
게시글 목록
| 번호 | 제목 |
|---|---|
| 20141 | |
| 20129 | |
| 20120 | |
| 20114 | |
| 20106 | |
| 20099 | |
| 20097 | |
| 20091 | |
| 20050 | |
| 20042 | |
| 20039 | |
| 20010 | |
| 19996 | |
| 19978 | |
| 19969 | |
| 19954 | |
| 19911 | |
| 19908 | |
| 19907 | |
| 19905 | |
| 19904 | |
| 19892 | |
| 19882 | |
| 19864 | |
| 19861 | |
| 19844 | |
| 19831 | |
| 19829 | |
| 19820 | |
| 19805 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기