JavaScript
-
[Input masking] JQuery 쓰지 않고 돈, % 마스킹하기JavaScript 2021. 2. 22. 15:25
돈 : 1,000,000 comma: function(str){ str = String(str); return str.replace(/(\d)(?=(?:\d{3})+(?!\d))/g, '$1,'); } uncomma: function(str){ str= String(str); return str.replace(/[^\d]+/g, ''); } inputCurrency: function(value){ return this.comma(this.uncomma(value)); } %: 100% percentage: function(value){ if (value !== '' && value !== undefined) { return Math.round(String(value)) + '%'; } else { ret..