[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개
게시글 목록
| 번호 | 제목 |
|---|---|
| 20497 | |
| 20496 | |
| 20467 | |
| 20455 | |
| 20448 | |
| 20447 | |
| 20446 | |
| 20428 | |
| 20424 | |
| 20421 | |
| 20404 | |
| 20402 | |
| 20401 | |
| 20389 | |
| 20350 | |
| 20345 | |
| 20333 | |
| 20307 | |
| 20286 | |
| 20284 | |
| 20281 | |
| 20280 | |
| 20239 | |
| 20235 | |
| 20226 | |
| 20197 | |
| 20192 | |
| 20189 | |
| 20166 | |
| 20147 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기