[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개
게시글 목록
| 번호 | 제목 |
|---|---|
| 19084 | |
| 19067 | |
| 19065 | |
| 19058 | |
| 19047 | |
| 19034 | |
| 19032 | |
| 19027 | |
| 18989 | |
| 18969 | |
| 18962 | |
| 18950 | |
| 18949 | |
| 18945 | |
| 18942 | |
| 18935 | |
| 18915 | |
| 18897 | |
| 18878 | |
| 18876 | |
| 18870 | |
| 18866 | |
| 18836 | |
| 18835 | |
| 18825 | |
| 18814 | |
| 18802 | |
| 18772 | |
| 18762 | |
| 18757 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기