/* history 2003.11.23 created by cho */ //check item valid functions function idkeyup(){ document.member_join_input_form.idCheckFlag.value="false"; } function nickkeyup(){ document.member_join_input_form.nickCheckFlag.value="false"; } /* check if is positive number include in float number 0 -> true -12 -> false 34 -> true 34.23 -> true */ function isPosNumber(val) { if( !isNumber(val) ) return false; return val >= 0 ; } /* check if is number 0 -> true 23.43 -> true -23.23 -> true 23 -> true asdd -> false #$% -> false 134s -> false */ function isNumber(val) { return !isNaN(val); } /* check if is integer value 0 -> true , 23 -> true -23 -> true 23.23 -> false -23.23 -> false afe23 -> false */ function isInteger(val) { if( !isNumber(val) ) return false; return val.indexOf('.') == -1; } /* 0~9 and a-Z : Not include '.' '-' 2343ASBfe -> true 23.34 -> false -234 -> false */ function isNumberAndAlpha(val) { if( val == null ) return false; for( i=0 ; i= 'a' && ch <= 'z') || (ch >= 'A' && ch <='Z') || (ch >='0' && ch <='9') ) continue; else return false; } return true; } /* check scale isScaleNumber("123.45",4) -> true isScaleNumber("123.45",3) -> true isScaleNumber("123.45",2) -> false isScaleNumber("123",4) -> true isScaleNumber("123",3) -> true isScaleNumber("123",2) -> false */ function isScaleNumber(val,size) { if( !isNumber(val) ) return false; pos = val.indexOf('.'); if( pos == -1 ) return val.length <= size ; else return pos <= size; } /*** With Length ***/ /* checkLength("abcde",6) -> false checkLength("abcde",5) -> true checkLength("abcde",4) -> true checkLength("abcde",6,3) -> false checkLength("abcde",5,3) -> true checkLength("ab",4,3) -> false checkLength("ab",4,2) -> true checkLength("ab",null,3) -> false checkLength("ab",null,2) -> true */ function checkLength(val,maxLength,minLength) { var result = true; if( maxLength != null ) if( val.length > maxLength ) result = false; if( minLength != null ) if( val.length < minLength ) result = false; return result; } /*** With Size ***/ /* checkSize("999",999) -> false checkSize("999",1000) -> false checkSize("999",998) -> true checkSize("0",998,0) -> false checkSize("1",998,0) -> true checkSize("1",null,0) -> true */ function checkSize(val,maxSize,minSize) { var result = true; if( maxSize != null ) if( val >= maxSize ) result = false; if( minSize != null ) if( val <= minSize ) result = false; return result; } // do not check for full-word character function hasBlank(val) { if( val == null ) return false; return val.indexOf(" ") != -1; } /* check if first character is alphabet isFirstAlphabet("a234") -> true isFirstAlphabet("234adf") -> false isFirstAlphabet("#asd") -> false */ function isFirstAlphabet(val) { // if val is null , invalid data. if( val == null ) return false; temp = val.charAt(0); return isConsistChar( temp , null , true , null ); } /* usage : isConsistChar("test23432%%$",true,true,"%$") => true */ function isConsistChar(val,isNum,isAlpha,specialChar) { alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; num = "0123456789"; if( val == null ) return false; var checkString=""; if( isNum ) checkString += num; if( isAlpha ) checkString += alpha; if( specialChar != null ) checkString += specialChar; for( i=0 ; i < val.length ; i++ ) if( checkString.indexOf( val.charAt( i ) ) == -1 ) return false; return true; } /** hasNotChar("1234%^&","%") => false hasNotChar("1234%^&","!@") => true **/ function hasNotChar(val,charList) { if( val == null ) return false; for( i=0 ; i false isNumAndHyphen("234-11") -> true isNumAndHyphen("23411") -> true */ function isNumAndHyphen(val) { return isConsistChar(val,true,false,"-"); } /* isNumberStr("2342") -> true isNumberStr("2342.234") -> false isNumberStr("-2342") -> false isNumberStr("afd") -> false */ function isNumberStr(val) { return isConsistChar(val,true,false,null); } function isNumberAndHyphen(val) { return isConsistChar(val,true,false,"-"); } /** usage : isHyphenPatten("345-2343","xxx-xxxx") ***/ function isHyphenPatten(val,patten) { if( val == null ) return false; if( patten == null ) return true; if( val.length != patten.length ) return false; for( i=0 ; i='0' && val.charAt(i) <='9' ) continue; else return false; else return false; } return true; } /* Check : YYYYMMDD isYYYYMMDD("11111111") -> true isYYYYMMDD("20031301") -> false 13 is not month value isYYYYMMDD("20031232") -> false 32 is not month value isYYYYMMDD("20030229") -> false 2003/02 has not '29' date isYYYYMMDD("20040229") -> true 2004/02 has '29' date isYYYYMMDD("00000000") -> false not allow 0000 - year , 00 - month , 00 - date */ function isYYYYMMDD(val) { if( val == null ) return false; if( val.length != 8 ) return false; if( !isNumberStr(val) ) return false; year = val.substring(0,4); month = val.substring(4,6); date = val.substring(6,8); if( year == "0000" ) return false; if( month > 12 || month == "00") return false; d = new Date( year , month ); maxDate = d.getUTCDate(); if( date > maxDate || date == "00" ) return false; return true; } /* Check : HHMM HH : 0 ~ 23 MI : 0 ~ 59 */ function isHH24MI(val) { if( val == null ) return false; if( val.length != 4 ) return false; if( !isNumberStr(val) ) return false; hour = val.substring(0,2); minute = val.substring(2,4); return hour <= 23 && minute <= 59; } /* check if has '&' or '<' */ function isXMLTextStr(val) { return hasNotChar(val,"&<"); } /* platform : "window" or "unix" or "linux" only checking for absolute path isFilePathStr("c:\aa\aa","window") -> true isFilePathStr("c:\aa\aa\aa?<>bb","window") -> false isFilePathStr("c\aa\aa","window") -> false isFilePathStr("aa\aa","window") -> false isFilePathStr("/aa/aa","unix") -> true isFilePathStr("/aa/aa/aa<>;aa","unix") -> false isFilePathStr("aa/aa/","unix") -> false */ function isFilePathStr(val,platform) { if( val == null || platform == null ) return false; if( platform == "window" ) { if( val.indexOf(":") != 2 ) return false; files = val.split("\\"); for( i=1 ; i|" checking characteres for unix and linux - &()|/`;\"'>< isFileNameStr("abcd#$","window") -> true isFileNameStr("abcd/:","window") -> false isFileNameStr("c:\aa","window") -> false isFileNameStr("asfc#$","unix") -> true isFileNameStr("asdf()","unix") -> false isFileNameStr("/asdf","unix") -> false */ function isFileNameStr(val,platform) { if( val == null || platform == null ) return false; if( platform == "window" ) { return hasNotChar( val , "\\/:*?\"<>|" ); }else if( platform == "unix" || platform == "linux" ) { return hasNotChar( val , "&()|/`;\"'><"); } } /* Add in 2005/09/04 */ function checkIsZenkaku(value) { for (var i = 0; i < value.length; ++i) { var c = value.charCodeAt(i); // ”¼ŠpƒJƒ^ƒJƒi‚Í•s‹–‰Â if (c < 256 || (c >= 0xff61 && c <= 0xff9f)) { return false; } } return true; } /* ‘SŠp‰p”Žš‚𔼊p‰p”Žš‚É’uŠ·‚·‚é */ function z2h_word(src) { return src.replace(/([‚`-‚y‚-‚š‚O-‚XQ])/g, function ($0) { return String.fromCharCode($0.charCodeAt(0) - 65248); }); } /* ”¼Šp‰p”Žš‚ð‘SŠp‰p”Žš‚É’uŠ·‚·‚é */ function h2z_word(src) { return src.replace(/(\w)/g, function ($0) { return String.fromCharCode($0.charCodeAt(0) + 65248); }); } function isZengakuNumberAndAlpha(val) { filter = /^[‚`-‚y‚-‚š‚O-‚XA-Za-z0-9]/ for (var i = 0; i < val.length; ++i) { var c = val.charAt(i); if( !filter.test(c) ) return false; } return true; } function checkLengthWithZengaku(val,maxLength,minLength) { var len = 0; for (var i = 0; i < val.length; ++i) { var c = val.charCodeAt(i); if (c < 256 || (c >= 0xff61 && c <= 0xff9f)) len +=1; else len +=2; } var result = true; if( maxLength != null ) if( len > maxLength ) result = false; if( minLength != null ) if( len < minLength ) result = false; return result; } function isEmail(val) { var idIndex = val.indexOf('@'); if( idIndex == -1 || idIndex == 0 || idIndex+1 == val.length ) return false; var domain = val.substring(idIndex+1); var dotIndex = domain.indexOf('.'); if( dotIndex == -1 || dotIndex == 0 || dotIndex+1 == domain.length ) return false; if( !hasNotChar(domain,",@") ) return false; return true; } function isValidId(val) { filter = /^[A-Za-z0-9‚ -‚ñƒA-ƒ“ˆŸ-üKã’†‰ºˆê“ñŽO”V‹v]/ for (var i = 0; i < val.length; ++i) { var c = val.charAt(i); if( !filter.test(c) ) return false; } return true; } function isValidNickName(val) { filter = /^[A-Za-z0-9‚ -‚ñƒA-ƒ“ˆŸ-üKã’†‰ºˆê“ñŽO”V‹v!_,.@~BDEHI`QUX|[‡‰Š“•–—ô^‚Ÿƒ”ƒ@ƒ•ƒ–]/; for (var i = 0; i < val.length; ++i) { var c = val.charAt(i); if( !filter.test(c) ) return false; } return true; } function isValidUserName(val) { filter = /^[A-Za-z0-9‚ -‚ñƒA-ƒ“ˆŸ-üKã’†‰ºˆê“ñŽO”V‹v]/; for (var i = 0; i < val.length; ++i) { var c = val.charAt(i); if( !filter.test(c) ) return false; } return true; } function Parameters() { this.names = new Array(); this.values = new Array(); this.put = parametersPut; this.get = parametersGet; this.toString = parametersToString; } /* put name=value pair */ function parametersPut(name, value) { this.names[this.names.length] = name; this.values[this.values.length] = value; } /* get value for given key */ function parametersGet(name) { for(var i=0; i "asb" trim("@asb ") -> "asb" */ function trim(val) { if( val == null ) return null; len = val.length; for( var i=0 ; i0 && ( val.charAt(j-1) ==' ' || val.charAt(j-1) == '@' ) ; j-- ) ; return i>=j ? "" : val.substring(i,j); } /* return the converted string for xml text value covertXMLTextStr("111&222") -> "111&222"; covertXMLTextStr("111<222") -> "111<222"; */ function covertXMLTextStr(val) { val = val.replace(/&/g,"&"); val = val.replace(/ oneOfTdInTable = document.all("abc"); moveScroll( oneOfTdInTable ); */ function moveScroll( obj ) { po = 0; for( p=obj ; p.nodeName != "BODY" ; p=p.offsetParent ) { po += p.offsetTop; } halfSize = document.body.offsetHeight/2; if ( po - halfSize > 0 ) po = po - halfSize; else po = 0; window.scroll(0, po ); } /* default compareMethod => compareOptionByValue Usage : sortSelect( document.job.MY_SELECT , myCompare ); sortSelect( document.job.MY_SELECT ); */ function sortSelect( obj , compareMethod ) { if( compareMethod == null ) compareMethod = compareOptionByValue; var arr = new Array(); for( i=obj.options.length-1 ; i>=0 ; i=obj.options.length-1 ) { arr[i] = obj.options[i]; obj.remove(i); } arr.sort( compareMethod ); for( var i=0 ; i v2 ) return 1; else if( v1 < v2 ) return -1; else return 0; } /* sample compareMethod For table function compareInt( a , b ) { aa = a.all.item(sortKey); bb = b.all.item(sortKey); first = aa.childNodes[0].nodeValue*1; second = bb.childNodes[0].nodeValue*1; if( first > second ) return descSort; else if( first < second ) return descSort*-1; else return 0; } */ function selectOption( selectObj , optionObj ) { for( var i=0 ; i "111%25222" "test.jsp?VALUE=111%222" => "test.jsp?VALUE=111%25222" */ function convertEscape(val) { if( val == null ) return null; val = val.replace(/%/g,"%25"); val = val.replace(/&/g,"%26"); val = val.replace(/#/g,"%23"); val = val.replace(/\?/g,"%3F"); val = val.replace(/=/g,"%3D"); return val; } function getScreenPosTop(obj) { po = 0; for(var p=obj ; p.nodeName != "BODY" ; p=p.offsetParent ) { po += p.offsetTop; } return po; } function getScreenPosLeft(obj) { po = 0; for(var p=obj ; p.nodeName != "BODY" ; p=p.offsetParent ) { po += p.offsetLeft; } return po; } //-----------inserted by tongmyung stert-------------- function onkeylengthMax(formobj,maxlength, objname) { //alert(formobj.value.length); var li_byte = 0; var li_len = 0; for(var i=0; i< formobj.value.length; i++){ if (escape(formobj.value.charAt(i)).length > 4){ li_byte += 2; } else{ li_byte++; } if(li_byte <= maxlength){ li_len = i + 1; } } if(li_byte > maxlength) { alert( objname + '‚Í‘SŠpŠî€' + (maxlength / 2) + 'ŽšˆÈ‰º‚Å쬂µ‚ĉº‚³‚¢B\n\nŒ»Ý‚Ì•¶Žš‚Ì’·‚³ ' + (li_byte / 2 ) + 'Žš'); formobj.value = formobj.value.substr(0, li_len); } formobj.focus(); } function isobj(formobj, objname, optpilsu, maxlength){ formobj.value = trim(formobj.value); var valuelen; valuelen = hlen(formobj.value); if (formobj == null ) { } else if (formobj.value == '' && optpilsu == 1){ alert(objname + '‚Í•K{“ü—Í€–Ú‚Å‚·B'); _cmdfocus(formobj); return false; } else if (arguments.length == 5 && arguments[4] > valuelen){ _cmdfocus(formobj); alert(objname + '‚Í‘SŠpŠî€ ' + (arguments[4]/2) + 'ŽšˆÈã‚Å쬂µ‚ĉº‚³‚¢B' + /*(‘SŠp‚Í ' + (arguments[4] / 2) + 'Žš)*/ '\n\nŒ»Ý‚Ì•¶Žš‚Ì’·‚³ ' + valuelen + 'Žš'); return false; } else if (valuelen > maxlength && maxlength != 0){ _cmdfocus(formobj); alert(objname + '‚Í‘SŠpŠî€ ' + (maxlength/2) + 'ŽšˆÈ‰º‚Å쬂µ‚ĉº‚³‚¢B' + /*(‘SŠp‚Í ' + (maxlength / 2) + 'Žš)*/ ' \n\nŒ»Ý‚Ì•¶Žš‚Ì’·‚³ ' + valuelen + 'Žš'); return false; } else { return true; } } function _cmdfocus(formobj){ if( formobj.style.display != "none") { formobj.select(); formobj.focus(); } } function hlen(objstr){ var i, j; var objcode; j = 0; //alert (objstr.length); for ( i = 0; i < objstr.length ; i++){ objcode = objstr.charCodeAt(i); // alert (objcode); objcode = parseInt(objcode); // alert (objcode); if ((objcode > 255) || (objcode < 0)){ j = j + 2; } else{ j = j + 1; } } return j; } //-----------inserted by tongmyung end--------------