/* JForm : °ËÁõÇÒ ¸ðµç °´Ã¼¸¦ ´ã´Âµ¥ »ç¿ë. JText : ÅØ½ºÆ® µ¥ÀÌÅ͸¦ °ËÁõÇϴµ¥ »ç¿ë. JNumber : ¼ýÀÚ µ¥ÀÌÅ͸¦ °ËÁõÇϴµ¥ »ç¿ë. JMoney : È­Æó µ¥ÀÌÅ͸¦ °ËÁõÇϴµ¥ »ç¿ë. JSelect : Drop/Down µ¥ÀÌÅ͸¦ °ËÁõÇϴµ¥ »ç¿ë. JChcek : üũ¹Ú½º¿Í ¶óµð¿À ¹öưÀ» °ËÁõÇϴµ¥ »ç¿ë. JSsn : Áֹεî·Ï¹øÈ£¸¦ °ËÁõÇϴµ¥ »ç¿ë. JMail : À̸ÞÀÏ ÁÖ¼Ò¸¦ °ËÁõÇϴµ¥ »ç¿ë. JDate : ³¯Â¥ µ¥ÀÌÅ͸¦ °ËÁõÇϴµ¥ »ç¿ë. JFile : ÆÄÀÏ ¾÷·Îµå µ¥ÀÌÅ͸¦ °ËÁõÇϴµ¥ »ç¿ë. */ var DAY_OF_WEEK = new Array("ÀÏ","¿ù","È­","¼ö","¸ñ","±Ý","Åä"); function JForm() { /* Member field */ this.children = new Array /* Member Method */ this.add = jform_add; this.validate = jform_validate; return this; } function jform_add(child) { this.children[this.children.length] = child; return this; } function jform_validate() { for (var i = 0; i < this.children.length; i++) { if (!this.children[i].validate()) { return false; } } return true; } function JText(name, object) { /* Member Field */ this.name = name; this.object = object; this.min; this.max; this.filterCheck; this.nullCheck = true; this.rangeCheck; /* Member Method */ this.validate = jtext_validate; this.nullable = jtext_nullable; this.range = jtext_range; this.filter = jtext_filter; this.focus = jtext_focus; return this; } function jtext_validate() { var value = this.object.value; if (this.nullCheck && trimmed(value).length == 0) { alert(ul(this.name) + " ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù."); return this.focus(); } if (this.rangeCheck && (trimmed(value).length != 0) && !checkCharacterSize(value, this.min, this.max)) { if (this.min == this.max) { alert(this.name + "ÀÇ Å©±â´Â " + this.min + "ÀÌ¿©¾ß ÇÕ´Ï´Ù"); } else { alert(this.name + "ÀÇ Å©±â´Â " + this.min + "°ú " + this.max + " »çÀÌ¿©¾ß ÇÕ´Ï´Ù"); } return this.focus(); } if (this.filterCheck && isSpecial(value)) { alert(this.name + "¿¡´Â ´ÙÀ½(', ., \") Ư¼ö ¹®ÀÚ´Â ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù."); return this.focus(); } return true; } function jtext_nullable() { this.nullCheck = false; return this; } function jtext_range(min, max) { this.rangeCheck = true; this.min = min; this.max = max; return this; } function jtext_filter() { this.filterCheck = true; return this; } function jtext_focus() { this.object.focus(); this.object.select(); return false; } function JNumber(name, object) { /* Member Field */ this.name = name; this.object = object; this.nullCheck = true; this.rangeCheck; this.min; this.max; /* Member Method */ this.validate = jnumber_validate; this.nullable = jtext_nullable; this.range = jtext_range; this.focus = jtext_focus; return this; } function jnumber_validate() { var value = this.object.value; if (this.nullCheck && trimmed(value).length == 0) { alert(ul(this.name) + " ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù."); return this.focus(); } if (isNaN(value)) { alert(this.name + "¿¡´Â ¼ýÀÚ¸¸À» ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù."); return this.focus(); } if (this.rangeCheck && (trimmed(value).length != 0) && !checkNumberSize(value, this.min, this.max)) { if (this.min == this.max) { alert(this.name + "ÀÇ ¼ýÀÚ´Â " + this.min + "ÀÌ¿©¾ß ÇÕ´Ï´Ù"); } else { alert(this.name + "ÀÇ ¼ýÀÚ´Â " + wa(this.min) + " " + this.max + " »çÀÌ¿©¾ß ÇÕ´Ï´Ù"); } return this.focus(); } return true; } function JSelect(name, object) { /* Member Field */ this.name = name; this.object = object; this.min; this.max; this.nullCheck = true; this.rangeCheck; /* Member Method */ this.validate = jselect_validate; this.nullable = jtext_nullable; this.range = jtext_range; this.focus = jselect_focus; return this; } function jselect_validate() { var value = this.object.value; if (this.nullCheck && trimmed(value).length == 0) { alert(ul(this.name) + " ¼±ÅÃÇØ¾ß ÇÕ´Ï´Ù."); return this.focus(); } var number = isSelected(this.object); if (this.rangeCheck && number != 0 && (number < this.min || number > this.max)) { if (this.min == this.max) { alert("¼±ÅÃÇÒ ¼ö ÀÖ´Â " + this.name + "ÀÇ ¼ö´Â " + this.min + "ÀÔ´Ï´Ù."); } else { alert("¼±ÅÃÇÒ ¼ö ÀÖ´Â " + this.name + "ÀÇ ¼ö´Â " + wa(this.min) + " " + this.max + " »çÀÌÀÔ´Ï´Ù."); } return this.focus(); } return true; } function jselect_focus() { this.object.focus(); return false; } function isSelected(item) { if (item == null) return 0; var result = 0; for (var i = 0; i < item.length; i++) { if (item[i].selected) { result++; } } return result; } function JCheck(name, object) { /* Member Field */ this.name = name; this.object = object; this.min; this.max; this.nullCheck = true; this.rangeCheck; /* Member Method */ this.validate = jcheck_validate; this.nullable = jtext_nullable; this.range = jtext_range; this.focus = jcheck_focus; return this; } function jcheck_validate() { var number = isChecked(this.object); if (this.nullCheck && number == 0) { alert(this.name + "À»(¸¦) ¼±ÅÃÇØ¾ß ÇÕ´Ï´Ù."); return this.focus(); } if (this.rangeCheck && number != 0 && (number < this.min || number > this.max)) { if (this.min == this.max) { alert("¼±ÅÃÇÒ ¼ö ÀÖ´Â " + this.name + "ÀÇ ¼ö´Â " + this.min + "ÀÔ´Ï´Ù."); } else { alert("¼±ÅÃÇÒ ¼ö ÀÖ´Â " + this.name + "ÀÇ ¼ö´Â " + wa(this.min) + " " + this.max + " »çÀÌÀÔ´Ï´Ù."); } return this.focus(); } return true; } function jcheck_focus() { return false; } function isSpecial(s) { for (i = 0; i < s.length; i++) { /* Check that current character letter. */ var c = s.charAt(i); if (c == "'" || c == "." || c == "\"") { return true; } } return false; } function isChecked(list) { if (list == null) return 0; var result = 0; /* list arrayÀÇ µ¥ÀÌÅͰ¡ 1ÀÎ °æ¿ì */ if (list.checked) { return 1; } for (var i = 0; i < list.length; i++) { if (list[i].checked) { result++; } } return result; } function trimmed(value) { value = value.replace(/^\s+/, ""); /* remove leading white spaces */ value = value.replace(/\s+$/g, ""); /* remove trailing while spaces */ return value; } function checkCharacterSize(data, min, max) { var total = 0; for (var i = 0; i < data.length; i++) { var a = data.charAt(i); /* ÇѱÛÀÎ °æ¿ì ±æÀ̰¡ 6 ÀÌ´Ù. */ if (escape(a).length >= 6) { total = total + 2; } else { total = total + 1; } } return total >= min && total <= max; } function checkNumberSize(data, min, max) { if(max <= 0) { return data >= min; } else { return data >= min && data <= max; } } function JMoney(name, object) { /* Member Field */ this.name = name; this.object = object; this.nullCheck = true; this.rangeCheck; this.min; this.max; /* Member Method */ this.validate = jmoney_validate; this.nullable = jtext_nullable; this.range = jtext_range; this.focus = jtext_focus; return this; } function jmoney_validate() { var value = this.object.value; if (this.nullCheck && trimmed(value).length == 0) { alert(ul(this.name) + " ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù."); return this.focus(); } value = value.replace(/,|\s+/g, ""); if (isNaN(value)) { alert(this.name + "¿¡´Â ¼ýÀÚ¸¸À» ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù."); return this.focus(); } if (this.rangeCheck && (trimmed(value).length != 0) && !checkNumberSize(value, this.min, this.max)) { if (this.min == this.max) { alert(this.name + "ÀÇ ±Ý¾×Àº " + this.min + "ÀÌ¿©¾ß ÇÕ´Ï´Ù"); } else { alert(this.name + "ÀÇ ±Ý¾×Àº " + wa(this.min) + " " + this.max + " »çÀÌ¿©¾ß ÇÕ´Ï´Ù"); } return this.focus(); } return true; } function JSsn(name, object) { /* Member Field */ this.name = name; this.object = object; this.nullCheck = true; /* Member Method */ this.validate = jssn_validate; this.nullable = jtext_nullable; this.focus = jtext_focus; return this; } function jssn_validate() { var value = this.object.value; if (isNaN(value.replace(/-|\s+/g, ""))) { alert(this.name + "¿¡´Â ¼ýÀÚ¸¸À» ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù."); return this.focus(); } if (!this.nullCheck && trimmed(value).length == 0) { return true; } var year = value.substring(0, 2); var month = value.substring(2, 4); var day = value.substring(4, 6); var sex = value.substring(13, 14); if ((value.length != 14 ) || (year < 25 || month < 1 || month >12 || day < 1)) { alert(ul(this.name) + " ¿Ã¹Ù¸£°Ô ÀÔ·ÂÇÏ¿© ÁֽʽÿÀ."); return this.focus(); } if ((sex != 1 && sex !=2 )) { alert(ul(this.name) + " ¿Ã¹Ù¸£°Ô ÀÔ·ÂÇÏ¿© ÁֽʽÿÀ."); return this.focus(); } return true; } function JMail(name, object) { /* Member Field */ this.name = name; this.object = object; this.nullCheck = true; /* Member Method */ this.validate = jmail_validate; this.nullable = jtext_nullable; this.focus = jtext_focus; return this; } function jmail_validate() { var value = this.object.value; if (this.nullCheck && trimmed(value).length == 0) { alert(ul(this.name) + " ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù."); return this.focus(); } if (!this.nullCheck && trimmed(value).length == 0) { return true; } /* À̸ÞÀÏ ÁÖ¼ÒÀÇ Çã¿ëµÇ´Â ÃÖ´ë Å©±â üũ */ var re = new RegExp("(^[_0-9a-zA-Z-]+(\.[_0-9a-zA-Z-]+)*@[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*$)"); if (!re.test(value)) { alert("ÀÔ·ÂÇϽŠ" + un(this.name) + " ÀüÀÚ¿ìÆíÁÖ¼Ò·Î À¯È¿ÇÏÁö ¾Ê½À´Ï´Ù. ´Ù½Ã ÀÔ·ÂÇÏ¿© ÁֽʽÿÀ!"); return this.focus(); } return true; } /** * Date ŸÀÔ °ËÁõ¿¡ »ç¿ëµÈ´Ù. */ function JDate(name, object, re) { /* Member Field */ this.name = name; this.object = object; this.nullCheck = true; this.rangeCheck = false; this.date = null; if (re) { this.re = re; } else { this.re = /^\d{4}[-.\/]?\d{2}[-.\/]?\d{2}$/; } this.min = null; /* YYYYMMDD Format */ this.max = null; /* YYYYMMDD Format */ this.format = "YYYY³âMM¿ùDDÀÏ(DAY)"; /* Member Method */ this.validate = jdate_validate; this.nullable = jtext_nullable; this.focus = jtext_focus; this.range = jtext_range; this.toDate = jdate_toDate; this.parse = jdate_parse; this.toString = jdate_toString; this.getYear = jdate_getYear; this.getMonth = jdate_getMonth; this.getDate = jdate_getDate; this.getDay = jdate_getDay; this.parse(); return this; } /* µ¥ÀÌÅÍ Å¸ÀÔ À¯È¿¼º Å×½ºÆ® */ function jdate_validate() { var value = this.object.value; if (this.nullCheck && trimmed(value).length == 0) { alert(this.name + "À»(¸¦) ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù."); return this.focus(); } if (!this.nullCheck && trimmed(value).length == 0) { return true; } if (this.date == null) { alert("ÀÔ·ÂÇϽŠ" + this.name + "Àº(´Â) ³¯Â¥·Î À¯È¿ÇÏÁö ¾Ê½À´Ï´Ù. ´Ù½Ã ÀÔ·ÂÇÏ¿© ÁֽʽÿÀ!"); return this.focus(); } if (this.rangeCheck) { var aDate = this.toDate(); var minDate, maxDate; if (this.min != null) { minDate = new JDate().parse(this.min); } else { minDate = new JDate().parse("10000101"); } if (this.max != null) { maxDate = new JDate().parse(this.max); } else { maxDate = new JDate().parse("99991231"); } if (this.min == null && aDate > maxDate.toDate()) { alert(this.name + "ÀÇ ³¯Â¥´Â " + maxDate + " ÀÌÀü À̾î¾ß ÇÕ´Ï´Ù."); return this.focus(); } else if (this.max == null && aDate < minDate.toDate()) { alert(this.name + "ÀÇ ³¯Â¥´Â " + minDate + " ÀÌÈÄ À̾î¾ß ÇÕ´Ï´Ù."); return this.focus(); } else if (aDate > maxDate.toDate() || aDate < minDate.toDate()) { alert(this.name + "ÀÇ ³¯Â¥´Â " + minDate + "°ú " + maxDate + " »çÀÌ¿©¾ß ÇÕ´Ï´Ù"); return this.focus(); } } return true; } /* Date ÆÄ½Ì */ /* ³¯Â¥ µ¥ÀÌÅÍ ÀÎÁö °ËÁõÇÑ´Ù. ÀÏÂ÷ÀûÀ¸·Î´Â Á¤±Ô½ÄÀ» ÀÌ¿ëÇÑ´Ù. */ /* ³â,¿ù,ÀÏ »çÀÌÀÇ Delimiter´Â ".-/" Áß ÇϳªÀ̰ųª ºó¹®ÀÚÀ» »ç¿ëÇÑ´Ù. */ /* Date Object¸¦ ÃʱâÈ­ÇÏ¿© µ¥ÀÌÅͰ¡ ÀûÇÕÇÑÁö üũÇÑ´Ù. */ function jdate_parse() { var value = this.object; if (jdate_parse.arguments.length > 0) { value = jdate_parse.arguments[0]; } else if (this.object && typeof this.object=="object") { value = this.object.value; } else { this.date = new Date(); return this; } this.date = null; if (value.search(this.re) >= 0) { value = value.replace(/[-.\/]/g,""); var aDate = new Date(value.substring(0,4),value.substring(4,6)-1,value.substring(6,8)); if ( aDate.getFullYear() == Math.abs(value.substring(0,4)) && aDate.getMonth() == Math.abs(value.substring(4,6))-1 && aDate.getDate() == Math.abs(value.substring(6,8)) ) { this.date = aDate; } } return this; } /* Date ŸÀÔÀ¸·Î º¯È¯ */ function jdate_toDate() { return this.date; } function jdate_getYear() { return this.date == null ? 1000 : this.date.getFullYear(); } function jdate_getMonth() { var num = (this.date == null ? 0 : this.date.getMonth()+1); return (num < 10 ? '0' + new String(num) : num); } function jdate_getDate() { var num = (this.date == null ? 0 : this.date.getDate()); return (num < 10 ? '0' + new String(num) : num); } function jdate_getDay() { return (this.date == null ? DAY_OF_WEEK[0] : DAY_OF_WEEK[this.date.getDay()]); } /* ½ºÆ®¸µÀ¸·Î º¯È¯ */ function jdate_toString() { var formatString = this.format; if (jdate_toString.arguments.length > 0) { formatString = jdate_toString.arguments[0]; } var str = formatString.replace(/YYYY/g , this.getYear()); str = str.replace(/MM/g , this.getMonth()); str = str.replace(/DD/g , this.getDate()); str = str.replace(/DAY/g , this.getDay()); str = str.replace(/yy/g , new String(this.getYear()).substring(2,4)); return str; } function JFile(name, type) { /* Member Field */ this.name = name; this.object = document.forms[0].j_file; this.type = type; this.nullCheck = true; this.allowedExtension; this.nullable = jtext_nullable; this.extension = jfile_extension; this.validate = jfile_validate; return this; } function jfile_extension(array) { this.allowedExtension = array; return this; } function jfile_validate() { if (this.nullCheck) { var countInputName = "j_file_count"; if (this.type) { countInputName += "_" + this.type; } var countInput = document.forms[0][countInputName]; if (!countInput || countInput.value < 1) { alert(this.name + "¿¡ ´ëÇÑ ÆÄÀÏÀ» ÷ºÎÇØ¾ß ÇÕ´Ï´Ù."); return false; } } if (this.allowedExtension) { var passed = true; for (var i = 0; i < this.object.length; i++) { if (this.type) { var spanNode = this.object[i].nextSibling; if (!spanNode || spanNode.getElementsByTagName("input")[0].value != this.type) { continue; } } var extension = this.object[i].value; if (trimmed(extension).length == 0) { continue; } var index = extension.lastIndexOf("."); if (index == -1) { passed = false; break; } extension = extension.substring(index + 1).toLowerCase(); for(var j = 0; j < this.allowedExtension.length ; j++) { if (this.allowedExtension[j].toLowerCase() == extension) { break; } if (j == this.allowedExtension.length - 1) { passed = false; } } } if (!passed) { alert(this.name + "¿¡ ´ëÇÑ Ã·ºÎ °¡´ÉÇÑ ÆÄÀÏÀÇ È®ÀåÀÚ´Â " + this.allowedExtension.join(", ") + " ÀÔ´Ï´Ù."); return false; } } return true; } /* ³»ºÎÇÔ¼ö (ÇÑ±Û Á¾¼ºÃ¼Å©) */ function isJongsong(wd) { var INDETERMINATE = 0; var NOJONGSONG = 1; var JONGSONG = 2; word = new String(wd); /* ¼ýÀÚ°¡ µé¾î¿À´Â µî¿¡ ´ëºñÇØ ¹«Á¶°Ç ¹®ÀÚ¿­·Î ¹Ù²Þ */ numStr1 = "013678lmnLMN"; /* 'Á¶' Àü±îÁö´Â 0ÀÌ ¹ÞħÀÌ Àִ°ɷΠ³ª¿È --; */ numStr2 = "2459aefhijkoqrsuvwxyzAEFHIJKOQRSUVWXYZ"; /* bdgptµéÀº Àб⿡ µû¶ó ¹ÞħÀÌ Àֱ⵵ ÇÏ°í ¾ø±âµµ ÇÑ´Ù°í ÆÇ´Ü. */ /* ´ë¹®ÀÚ´Â ´Üµ¶À¸·Î ÀÐÀ» ¶§¸¦ °¨¾ÈÇÏ¸é ¹Þħ ÀÖ´Ù°í È®Á¤µÇ´Â °ÍÀÌ ´õ ÀûÀ½. */ if (word == null || word.length < 1) { return INDETERMINATE; } lastChar = word.charAt(word.length - 1); lastCharCode = word.charCodeAt(word.length - 1); if (numStr1.indexOf(lastChar) > -1) { return JONGSONG; }else if (numStr2.indexOf(lastChar) > -1) { return NOJONGSONG; } if (lastCharCode<0xac00 || lastCharCode>0xda0c) { return INDETERMINATE; } else{ lastjongseong = (lastCharCode - 0xAC00) % (21*28) % 28 ; if (lastjongseong == 0){ return NOJONGSONG; }else{ return JONGSONG; } } } /* ³»ºÎÇÔ¼ö (À»/¸¦) */ function ul(s) { var ul0 = new Array("(À»)¸¦", "¸¦", "À»"); return s + ul0[isJongsong(s)]; } /* ³»ºÎÇÔ¼ö (ÀÌ/°¡) */ function ka(s){ var ka0 = new Array("(ÀÌ)°¡", "°¡", "ÀÌ"); return s + ka0[isJongsong(s)]; } /* ³»ºÎÇÔ¼ö (Àº/´Â) */ function un(s){ var un0 = new Array("(Àº)´Â", "´Â", "Àº"); return s + un0[isJongsong(s)]; } /* ³»ºÎÇÔ¼ö (¿Í/°ú) */ function wa(s){ var arr = new Array("(¿Í)°ú", "¿Í", "°ú"); return s + arr[isJongsong(s)]; }