/* * class 사용 * * entrKey - fn_enter()함수 호출 * intCheck - 숫자만 입력 가능 * floatCheck - 소수점 숫자만 입력 가능 * notHangul - 영문,숫자만 입력 가능 * timeCheck - 시간,분 체크 * **/ $(document).ready(function() { //fn_enter()함수 호출 $(".entrKey").keypress(function(e) { if('13' == e.keyCode){ if( typeof(fn_enter) == 'function' ) { fn_enter(1); }else if( typeof(goSearch) == 'function' ) { goSearch(1); } return false; } }); //(숫자만 입력 가능) $(".intCheck").css('imeMode', 'disabled').keypress(function(event) { if (event.which && (event.which < 48 || event.which > 57)) { event.preventDefault(); } }).keyup(function() { if ($(this).val() != null && $(this).val() != '') { $(this).val($(this).val().replace(/[^0-9]/g, '')); } }); //정수만 입력 $(".floatCheck").css('imeMode', 'disabled'); $(document).on('keypress', ".floatCheck", function(event) { if (event.which && ( (event.which != 45 && event.which < 48) || event.which > 57)&& (event.which != 46)) { event.preventDefault(); } }).on('focusout', ".floatCheck", function() { //console.log($(this).attr("max")); if ($(this).val() != null && $(this).val() != '') { if (isNaN(Number($(this).val()))) { alert("잘못된 값입니다."); $(this).val(''); $(this).focus(); } } }).on('keyup', ".floatCheck62", function() { var num = $(this).val(); var pattern = /^(\d{1,6})([.]\d{0,2}?)?$/; // 정규식 if ( !pattern.test(num) && num != '') { if ( num.indexOf('.') > 0) { // 정수인지 아닌지 판별 num = Number(num); //num = Math.floor(num*100)/100; num = num.toFixed(2); } else { num = num.substring(0,6); } $(this).val(num); } }).on('keyup', ".floatCheck64", function() { var num = $(this).val(); var pattern = /^(\d{1,6})([.]\d{0,4}?)?$/; // 정규식 if ( !pattern.test(num) && num != '') { if ( num.indexOf('.') > 0) { // 정수인지 아닌지 판별 num = Number(num); //num = Math.floor(num*100)/100; num = num.toFixed(4); } else { num = num.substring(0,6); } $(this).val(num); } }); $(".floatCheckEtc").css('imeMode', 'disabled'); $(document).on('keypress', ".floatCheckEtc", function(event) { console.log($(this).attr("class")); if (event.which && ( (event.which != 45 && event.which < 48) || event.which > 57)&& (event.which != 46)) { event.preventDefault(); } }).on('focusout', ".floatCheckEtc", function() { if ($(this).val() != null && $(this).val() != '') { if (isNaN(Number($(this).val())) && $(this).val() != "-") { alert("잘못된 값입니다."); $(this).val(''); $(this).focus(); $(this).css("background-color", "#ffffff"); } } }).on('keyup', ".floatCheckEtc", function() { var classNm = $(this).attr("class"); if(classNm.indexOf("cipher") > 0 ){ var cipher = parseInt(classNm.substr(classNm.indexOf("cipher")+6)); var num = $(this).val(); if ( !isNaN(Number($(this).val())) && num != '') { if ( num.indexOf('.') > 0) { // 정수인지 아닌지 판별 if(num.substr(num.indexOf('.')+1).length > cipher){ num = Number(num); num = num.toFixed(cipher); } } else { num = num.substring(0,15); } $(this).val(num); } } }); //(영문,숫자만 입력 가능) $(".notHangul").css('imeMode', 'disabled').keypress( function(event) { if (event.keyCode >= 37 && event.keyCode <= 40) { event.preventDefault(); } }).keyup(function() { if ($(this).val() != null && $(this).val() != '') { $(this).val($(this).val().replace(/[^a-z0-9]/gi, '')); } }); //시간,분 체크 $(".timeCheck").keyup(function() { var time = this.value; if (time.length == 4) { var t1 = time.substr(0, 2); var t2 = time.substr(2, 2); if (t1 > 23) { alert("잘못된 시간입니다 \n다시입력하세요"); this.value = ""; this.focus(); return; } if (t2 > 59) { alert("잘못된 시간입니다 \n다시입력하세요"); this.value = ""; this.focus(); return; } time = time.substr(0, 2) + ":" + time.substr(2, 2); this.value = time; } }); $(document).on('click', ".selRow tbody tr", function() { if($(this).parent().parent().parent().attr("class")=='colTable'){ // }else{ $(this).addClass("on"); $(this).siblings().removeClass("on"); } }); }); /** * 필수값 체크 함수 * gfnValidate(document.editForm); * @param frm * @returns {Boolean} */ function gfnValidate(frm) { var returnVal = true; $(".errInpt").removeClass("errInpt"); var cnObj = $(frm).find(".checkNull"); for(var i = 0; i -1 && obj.value != "" && obj.value != undefined) return true; else return false; } else if (obj.type == "checkbox" || obj.type == "radio") { if ($('input[name=' + obj.name + ']:checked').length > 0) return true; else return false; } else { // 추가 공백 체크 부분 2013.08.14 if (frmTrim(obj.value).length == 0) { return false; } else { // input type file은 값을 삽입 할 수 없다. 더이상 지원하지 않는다고 합니다. if (obj.type != "file") { obj.value = frmTrim(obj.value); } } if (obj.style.display != "none" && obj.value == "") { return false; } else { return true; } } } } /** * trim 추가 */ function frmTrim(str) { return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); } /* * * 같은 값이 있는 열을 병합함 * * 사용법 : $('#테이블 ID').rowspan (0); * */ $.fn.rowspan = function(colIdx, isStats) { return this.each(function(){ var that; $('tr', this).each(function(row) { $('th:eq('+colIdx+')', this).filter(':visible').each(function(col) { if ($(this).html() == $(that).html() && (!isStats || isStats && $(this).prev().html() == $(that).prev().html() ) ) { rowspan = $(that).attr("rowspan") || 1; rowspan = Number(rowspan)+1; $(that).attr("rowspan",rowspan); // do your action for the colspan cell here $(this).hide(); //$(this).remove(); // do your action for the old cell here } else { that = this; } // set the that if not already set that = (that == null) ? this : that; }); }); /*$('tr', this).each(function(row) { $('th:eq('+colIdx+')', this).filter(':hidden').each(function(col) { $(this).remove(); }); });*/ }); }; /* * * 같은 값이 있는 행을 병합함 * * 사용법 : $('#테이블 ID').colspan (0); * */ $.fn.colspan = function(rowIdx) { return this.each(function(){ var that; $('tr', this).filter(":eq("+rowIdx+")").each(function(row) { $(this).find('th').filter(':visible').each(function(col) { if ($(this).html() == $(that).html()) { colspan = $(that).attr("colSpan") || 1; colspan = Number(colspan)+1; //$(that).attr("colSpan",colspan).addClass('sorter-false'); $(that).attr("colSpan",colspan); $(this).hide(); // .remove(); } else { that = this; } // set the that if not already set that = (that == null) ? this : that; }); }); /*$('tr', this).filter(":eq("+rowIdx+")").each(function(row) { $(this).find('th').filter(':hidden').each(function(col) { $(this).remove(); }); });*/ }); }; /* * * 같은 값이 있는 행을 병합함 td용 * * 사용법 : $('#테이블 ID').colspan (0); * */ $.fn.rowspanTd = function(colIdx, isStats) { return this.each(function(){ var that; $('tr', this).each(function(row) { $('td:eq('+colIdx+')', this).filter(':visible').each(function(col) { if ($(this).html() == $(that).html() && (!isStats || isStats && $(this).prev().html() == $(that).prev().html() ) ) { rowspan = $(that).attr("rowspan") || 1; rowspan = Number(rowspan)+1; $(that).attr("rowspan",rowspan); // do your action for the colspan cell here $(this).hide(); //$(this).remove(); // do your action for the old cell here } else { that = this; } // set the that if not already set that = (that == null) ? this : that; }); }); /*$('tr', this).each(function(row) { $('th:eq('+colIdx+')', this).filter(':hidden').each(function(col) { $(this).remove(); }); });*/ }); };