(function ($) { // ¼ýÀÚ Á¦¿ÜÇÏ°í ¸ðµç ¹®ÀÚ »èÁ¦. $.fn.removeText = function(_v){ //console.log("removeText: ¼ýÀÚ Á¦°Å ÇÕ´Ï´Ù."); if (typeof(_v)==="undefined") { $(this).each(function(){ this.value = this.value.replace(/[^0-9]/g,''); }); } else { return _v.replace(/[^0-9]/g,''); } }; // phpÀÇ number_format°ú °°Àº È¿°ú. $.fn.numberFormat = function(_v){ this.proc = function(_v){ var tmp = '', number = '', cutlen = 3, comma = ',' i = 0, len = _v.length, mod = (len % cutlen), k = cutlen - mod; for (i; i < len; i++) { number = number + _v.charAt(i); if (i < len - 1) { k++; if ((k % cutlen) == 0) { number = number + comma; k = 0; } } } return number; }; var proc = this.proc; if (typeof(_v)==="undefined") { $(this).each(function(){ this.value = proc($(this).removeText(this.value)); }); } else { return proc(_v); } }; // ¼ýÀÚ ¸¸ Ç¥Çö $.fn.onlyNumber = function (p) { $(this).each(function(i) { //$(this).attr({'style':'text-align:right'}); this.value = $(this).removeText(this.value); $(this).bind('keypress keyup',function(e){ this.value = $(this).removeText(this.value); }); }); }; //¼ýÀÚ Ç¥Çö + Æ÷¸ä $.fn.onlyNumberFormat = function (p) { $(this).each(function(i) { //$(this).attr({'style':'text-align:right'}); this.value = $(this).removeText(this.value); this.value = $(this).numberFormat(this.value); $(this).bind('keypress keyup',function(e){ this.value = $(this).removeText(this.value); this.value = $(this).numberFormat(this.value); }); }); }; })(jQuery);