[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개
게시글 목록
| 번호 | 제목 |
|---|---|
| 19784 | |
| 19770 | |
| 19769 | |
| 19768 | |
| 19767 | |
| 19760 | |
| 19751 | |
| 19747 | |
| 19744 | |
| 19743 | |
| 19741 | |
| 19654 | |
| 19652 | |
| 19649 | |
| 19631 | |
| 19606 | |
| 19603 | |
| 19580 | |
| 19553 | |
| 19541 | |
| 19529 | |
| 19510 | |
| 19507 | |
| 19498 | |
| 19493 | |
| 19492 | |
| 19475 | |
| 19474 | |
| 19471 | |
| 19462 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기