반응형
function AddComma(num)
{
var regexp = /\B(?=(\d{3})+(?!\d))/g;
return num.toString().replace(regexp, ',');
}
function removeComma(str)
{
n = parseInt(str.replace(/,/g,""));
return n;
}
function numberWithCommas(x) {
x = x.replace(/[^0-9]/g,''); // 입력값이 숫자가 아니면 공백
x = x.replace(/,/g,''); // ,값 공백처리
$('input[name="so_use_point"]').val(x.replace(/\B(?=(\d{3})+(?!\d))/g, ",")); // 정규식을 이용해서 3자리 마다 , 추가
}
*$(cost_p).text(AddComma(cost_real)); 으로 사용!
728x90
반응형
'JS & jQuery' 카테고리의 다른 글
자바스크립트 배열 (0) | 2022.03.07 |
---|---|
휴대폰 인증시간 js (0) | 2022.03.07 |
이미지 저장막기 (0) | 2022.03.07 |
반원그리기 (0) | 2022.03.07 |
modal (0) | 2022.02.08 |