if (typeof(WREST_JS) == 'undefined') // Çѹø¸¸ ½ÇÇà { if (typeof g4_path == 'undefined') alert('g4_path º¯¼ö°¡ ¼±¾ðµÇÁö ¾Ê¾Ò½À´Ï´Ù. js/wrest.js'); var WREST_JS = true; var wrestMsg = ''; var wrestFld = null; //var wrestFldDefaultColor = '#FFFFFF'; var wrestFldDefaultColor = ''; var wrestFldBackColor = '#FFE4E1'; var arrAttr = new Array ('required', 'trim', 'minlength', 'email', 'hangul', 'hangul2', 'memberid', 'nospace', 'numeric', 'alpha', 'alphanumeric', 'jumin', 'saupja', 'alphanumericunderline', 'telnumber', 'hangulalphanumeric'); // subject ¼Ó¼º°ªÀ» ¾ò¾î return, ¾øÀ¸¸é tagÀÇ nameÀ» ³Ñ±è function wrestItemname(fld) { var itemname = fld.getAttribute("itemname"); if (itemname != null && itemname != "") return itemname; else return fld.name; } // ¾çÂÊ °ø¹é ¾ø¾Ö±â function wrestTrim(fld) { var pattern = /(^\s*)|(\s*$)/g; // \s °ø¹é ¹®ÀÚ fld.value = fld.value.replace(pattern, ""); return fld.value; } // Çʼö ÀÔ·Â °Ë»ç function wrestRequired(fld) { if (wrestTrim(fld) == "") { if (wrestFld == null) { // 3.30 // ¼¿·ºÆ®¹Ú½ºÀÏ °æ¿ì¿¡µµ Çʼö ¼±Åà °Ë»çÇÕ´Ï´Ù. wrestMsg = wrestItemname(fld) + " : Çʼö "+(fld.type=="select-one"?"¼±ÅÃ":"ÀÔ·Â")+"ÀÔ´Ï´Ù.\n"; wrestFld = fld; } } } // ÃÖ¼Ò ±æÀÌ °Ë»ç function wrestMinlength(fld) { var len = fld.getAttribute("minlength"); if (fld.value.length < len) { if (wrestFld == null) { wrestMsg = wrestItemname(fld) + " : ÃÖ¼Ò " + len + "ÀÚ ÀÌ»ó ÀÔ·ÂÇϼ¼¿ä.\n"; wrestFld = fld; } } } // ±è¼±¿ë 2006.3 - ÀüÈ­¹øÈ£(ÈÞ´ëÆù) Çü½Ä °Ë»ç : 123-123(4)-5678 function wrestTelnumber(fld){ if (!wrestTrim(fld)) return; var pattern = /^[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}$/; if(!pattern.test(fld.value)){ if(wrestFld == null){ wrestMsg = wrestItemname(fld)+" : ÀüÈ­¹øÈ£ Çü½ÄÀÌ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.\n\nÇÏÀÌÇÂ(-)À» Æ÷ÇÔÇÏ¿© ÀÔ·ÂÇØ ÁֽʽÿÀ.\n"; wrestFld = fld; fld.select(); } } } // À̸ÞÀÏÁÖ¼Ò Çü½Ä °Ë»ç function wrestEmail(fld) { if (!wrestTrim(fld)) return; //var pattern = /(\S+)@(\S+)\.(\S+)/; À̸ÞÀÏÁÖ¼Ò¿¡ ÇÑ±Û »ç¿ë½Ã var pattern = /([0-9a-zA-Z_-]+)@([0-9a-zA-Z_-]+)\.([0-9a-zA-Z_-]+)/; if (!pattern.test(fld.value)) { if (wrestFld == null) { wrestMsg = wrestItemname(fld) + " : À̸ÞÀÏÁÖ¼Ò Çü½ÄÀÌ ¾Æ´Õ´Ï´Ù.\n"; wrestFld = fld; } } } // ȸ¿ø¾ÆÀ̵ð °Ë»ç function wrestMemberId(fld) { if (!wrestTrim(fld)) return; var pattern = /(^([a-z0-9]+)([a-z0-9_]+$))/; if (!pattern.test(fld.value)) { if (wrestFld == null) { wrestMsg = wrestItemname(fld) + " : ȸ¿ø¾ÆÀ̵ð Çü½ÄÀÌ ¾Æ´Õ´Ï´Ù.\n\n¿µ¼Ò¹®ÀÚ, ¼ýÀÚ, _ ¸¸ °¡´É.\n\nù±ÛÀÚ´Â ¿µ¼Ò¹®ÀÚ, ¼ýÀÚ¸¸ °¡´É\n"; wrestFld = fld; } } } // ÇѱÛÀÎÁö °Ë»ç (ÀÚÀ½, ¸ðÀ½¸¸ ÀÖ´Â ÇѱÛÀº ºÒ°¡) function wrestHangul(fld) { if (!wrestTrim(fld)) return; var pattern = /([^°¡-힣\x20])/i; if (pattern.test(fld.value)) { if (wrestFld == null) { wrestMsg = wrestItemname(fld) + ' : ÇѱÛÀÌ ¾Æ´Õ´Ï´Ù. (ÀÚÀ½, ¸ðÀ½¸¸ ÀÖ´Â ÇѱÛÀº ó¸®ÇÏÁö ¾Ê½À´Ï´Ù.)\n'; wrestFld = fld; } } } // ÇѱÛÀÎÁö °Ë»ç2 (ÀÚÀ½, ¸ðÀ½¸¸ ÀÖ´Â Çѱ۵µ °¡´É) function wrestHangul2(fld) { if (!wrestTrim(fld)) return; var pattern = /([^°¡-힣¤¡-¤¾¤¿-¤Ó\x20])/i; if (pattern.test(fld.value)) { if (wrestFld == null) { wrestMsg = wrestItemname(fld) + ' : ÇѱÛÀÌ ¾Æ´Õ´Ï´Ù.\n'; wrestFld = fld; } } } // ÇѱÛ,¿µ¹®,¼ýÀÚÀÎÁö °Ë»ç3 function wrestHangulAlphaNumeric(fld) { if (!wrestTrim(fld)) return; var pattern = /([^°¡-힣\x20^a-z^A-Z^0-9])/i; if (pattern.test(fld.value)) { if (wrestFld == null) { wrestMsg = wrestItemname(fld) + ' : ÇѱÛ, ¿µ¹®, ¼ýÀÚ°¡ ¾Æ´Õ´Ï´Ù.\n'; wrestFld = fld; } } } // ¼ýÀÚÀÎÁö°Ë»ç // ¹èºÎ¸¥²Ü²ÜÀÌ´Ô Ãß°¡ (http://dasir.com) 2003-06-24 function wrestNumeric(fld) { if (fld.value.length > 0) { for (i = 0; i < fld.value.length; i++) { if (fld.value.charAt(i) < '0' || fld.value.charAt(i) > '9') { wrestMsg = wrestItemname(fld) + " : ¼ýÀÚ°¡ ¾Æ´Õ´Ï´Ù.\n"; wrestFld = fld; } } } } // ¿µ¹®ÀÚ °Ë»ç // ¹èºÎ¸¥²Ü²ÜÀÌ´Ô Ãß°¡ (http://dasir.com) 2003-06-24 function wrestAlpha(fld) { if (!wrestTrim(fld)) return; var pattern = /(^[a-zA-Z]+$)/; if (!pattern.test(fld.value)) { if (wrestFld == null) { wrestMsg = wrestItemname(fld) + " : ¿µ¹®ÀÌ ¾Æ´Õ´Ï´Ù.\n"; wrestFld = fld; } } } // ¿µ¹®ÀÚ¿Í ¼ýÀÚ °Ë»ç // ¹èºÎ¸¥²Ü²ÜÀÌ´Ô Ãß°¡ (http://dasir.com) 2003-07-07 function wrestAlphaNumeric(fld) { if (!wrestTrim(fld)) return; var pattern = /(^[a-zA-Z0-9]+$)/; if (!pattern.test(fld.value)) { if (wrestFld == null) { wrestMsg = wrestItemname(fld) + " : ¿µ¹® ¶Ç´Â ¼ýÀÚ°¡ ¾Æ´Õ´Ï´Ù.\n"; wrestFld = fld; } } } // ¿µ¹®ÀÚ¿Í ¼ýÀÚ ±×¸®°í _ °Ë»ç function wrestAlphaNumericUnderLine(fld) { if (!wrestTrim(fld)) return; var pattern = /(^[a-zA-Z0-9\_]+$)/; if (!pattern.test(fld.value)) { if (wrestFld == null) { wrestMsg = wrestItemname(fld) + " : ¿µ¹®, ¼ýÀÚ, _ °¡ ¾Æ´Õ´Ï´Ù.\n"; wrestFld = fld; } } } // Áֹεî·Ï¹øÈ£ °Ë»ç function wrestJumin(fld) { if (!wrestTrim(fld)) return; var pattern = /(^[0-9]{13}$)/; if (!pattern.test(fld.value)) { if (wrestFld == null) { wrestMsg = wrestItemname(fld) + " : Áֹεî·Ï¹øÈ£¸¦ 13ÀÚ¸® ¼ýÀÚ·Î ÀÔ·ÂÇϽʽÿÀ.\n"; wrestFld = fld; } } else { var sum_1 = 0; var sum_2 = 0; var at=0; var juminno= fld.value; sum_1 = (juminno.charAt(0)*2)+ (juminno.charAt(1)*3)+ (juminno.charAt(2)*4)+ (juminno.charAt(3)*5)+ (juminno.charAt(4)*6)+ (juminno.charAt(5)*7)+ (juminno.charAt(6)*8)+ (juminno.charAt(7)*9)+ (juminno.charAt(8)*2)+ (juminno.charAt(9)*3)+ (juminno.charAt(10)*4)+ (juminno.charAt(11)*5); sum_2=sum_1 % 11; if (sum_2 == 0) at = 10; else { if (sum_2 == 1) at = 11; else at = sum_2; } att = 11 - at; // 1800 ³â´ë¿¡ ž½Å ºÐµéÀº ³²ÀÚ, ¿©ÀÚÀÇ ±¸ºÐÀÌ 9, 0 À̶ó´Â // ¾ê±â¸¦ µéÀºÀûÀÌ Àִµ¥ ±×·¸´Ù¸é ¾Æ·¡ÀÇ ±¸¹®Àº ¿À·ùÀÌ´Ù. // ÇÏÁö¸¸... 100»ì³ÑÀº ºÐµéÀÌ Áֹεî·Ï¹øÈ£¸¦ °ú¿¬ ÀÔ·ÂÇغ¼±î? if (juminno.charAt(12) != att || juminno.substr(2,2) < '01' || juminno.substr(2,2) > '12' || juminno.substr(4,2) < '01' || juminno.substr(4,2) > '31' || juminno.charAt(6) > 4) { wrestMsg = wrestItemname(fld) + " : ¿Ã¹Ù¸¥ Áֹεî·Ï¹øÈ£°¡ ¾Æ´Õ´Ï´Ù.\n"; wrestFld = fld; } } } // »ç¾÷ÀÚµî·Ï¹øÈ£ °Ë»ç function wrestSaupja(fld) { if (!wrestTrim(fld)) return; var pattern = /(^[0-9]{10}$)/; if (!pattern.test(fld.value)) { if (wrestFld == null) { wrestMsg = wrestItemname(fld) + " : »ç¾÷ÀÚµî·Ï¹øÈ£¸¦ 10ÀÚ¸® ¼ýÀÚ·Î ÀÔ·ÂÇϽʽÿÀ.\n"; wrestFld = fld; } } else { var sum = 0; var at = 0; var att = 0; var saupjano= fld.value; sum = (saupjano.charAt(0)*1)+ (saupjano.charAt(1)*3)+ (saupjano.charAt(2)*7)+ (saupjano.charAt(3)*1)+ (saupjano.charAt(4)*3)+ (saupjano.charAt(5)*7)+ (saupjano.charAt(6)*1)+ (saupjano.charAt(7)*3)+ (saupjano.charAt(8)*5); sum += parseInt((saupjano.charAt(8)*5)/10); at = sum % 10; if (at != 0) att = 10 - at; if (saupjano.charAt(9) != att) { wrestMsg = wrestItemname(fld) + " : ¿Ã¹Ù¸¥ »ç¾÷ÀÚµî·Ï¹øÈ£°¡ ¾Æ´Õ´Ï´Ù.\n"; wrestFld = fld; } } } // °ø¹é °Ë»çÈÄ °ø¹éÀ» "" ·Î º¯È¯ function wrestNospace(fld) { var pattern = /(\s)/g; // \s °ø¹é ¹®ÀÚ if (pattern.test(fld.value)) { if (wrestFld == null) { wrestMsg = wrestItemname(fld) + " : °ø¹éÀÌ ¾ø¾î¾ß ÇÕ´Ï´Ù.\n"; wrestFld = fld; } } } // submit ÇÒ ¶§ ¼Ó¼ºÀ» °Ë»çÇÑ´Ù. function wrestSubmit() { wrestMsg = ""; wrestFld = null; var attr = null; // ÇØ´çÆû¿¡ ´ëÇÑ ¿ä¼ÒÀÇ °¹¼ö¸¸Å­ µ¹·Á¶ó for (var i = 0; i < this.elements.length; i++) { // Input tag ÀÇ type ÀÌ text, file, password À϶§¸¸ // 3.30 // ¼¿·ºÆ® ¹Ú½ºÀ϶§µµ Çʼö ¼±Åà °Ë»çÇÕ´Ï´Ù. select-one if (this.elements[i].type == "text" || this.elements[i].type == "file" || this.elements[i].type == "password" || this.elements[i].type == "select-one" || this.elements[i].type == "textarea") { // ¹è¿­ÀÇ ±æÀ̸¸Å­ µ¹·Á¶ó for (var j = 0; j < arrAttr.length; j++) { // ¹è¿­¿¡ Á¤ÀÇÇÑ ¼Ó¼º°ú ºñ±³Çؼ­ ¼Ó¼ºÀÌ Àְųª °ªÀÌ ÀÖ´Ù¸é if (this.elements[i].getAttribute(arrAttr[j]) != null) { /* // ±âº» »ö»óÀ¸·Î µ¹·Á³õ°í if (this.elements[i].getAttribute("required") != null) { this.elements[i].style.backgroundColor = wrestFldDefaultColor; } */ switch (arrAttr[j]) { case "required" : wrestRequired(this.elements[i]); break; case "trim" : wrestTrim(this.elements[i]); break; case "minlength" : wrestMinlength(this.elements[i]); break; case "email" : wrestEmail(this.elements[i]); break; case "hangul" : wrestHangul(this.elements[i]); break; case "hangul2" : wrestHangul2(this.elements[i]); break; case "hangulalphanumeric" : wrestHangulAlphaNumeric(this.elements[i]); break; case "memberid" : wrestMemberId(this.elements[i]); break; case "nospace" : wrestNospace(this.elements[i]); break; case "numeric" : wrestNumeric(this.elements[i]); break; case "alpha" : wrestAlpha(this.elements[i]); break; case "alphanumeric" : wrestAlphaNumeric(this.elements[i]); break; case "alphanumericunderline" : wrestAlphaNumericUnderLine(this.elements[i]); break; case "jumin" : wrestJumin(this.elements[i]); break; case "saupja" : wrestSaupja(this.elements[i]); break; // ±è¼±¿ë 2006.3 - ÀüÈ­¹øÈ£ Çü½Ä °Ë»ç case "telnumber" : wrestTelnumber(this.elements[i]); break; default : break; } } } } } // Çʵ尡 null ÀÌ ¾Æ´Ï¶ó¸é ¿À·ù¸Þ¼¼Áö Ãâ·ÂÈÄ Æ÷Ä¿½º¸¦ ÇØ´ç ¿À·ù Çʵå·Î ¿Å±è // ¿À·ù Çʵå´Â ¹è°æ»ö»óÀ» ¹Ù²Û´Ù. if (wrestFld != null) { alert(wrestMsg); if (wrestFld.style.display != 'none') { wrestFld.style.backgroundColor = wrestFldBackColor; wrestFld.focus(); } return false; } if (this.oldsubmit && this.oldsubmit() == false) return false; return true; } // Ãʱ⿡ onsubmitÀ» °¡·Îäµµ·Ï ÇÑ´Ù. function wrestInitialized() { for (var i = 0; i < document.forms.length; i++) { // onsubmit À̺¥Æ®°¡ ÀÖ´Ù¸é ÀúÀåÇØ ³õ´Â´Ù. if (document.forms[i].onsubmit) document.forms[i].oldsubmit = document.forms[i].onsubmit; document.forms[i].onsubmit = wrestSubmit; for (var j = 0; j < document.forms[i].elements.length; j++) { // Çʼö ÀÔ·ÂÀÏ °æ¿ì´Â * ¹è°æÀ̹ÌÁö¸¦ ÁØ´Ù. if (document.forms[i].elements[j].getAttribute("required") != null) { //document.forms[i].elements[j].style.backgroundColor = wrestFldDefaultColor; //document.forms[i].elements[j].className = "wrest_required"; document.forms[i].elements[j].style.backgroundImage = "url("+g4_path+"/js/wrest.gif)"; document.forms[i].elements[j].style.backgroundPosition = "top right"; document.forms[i].elements[j].style.backgroundRepeat = "no-repeat"; } } } } wrestInitialized(); }