티스토리 뷰

program

[js] util.js & validation.js

littlecarbb 2016. 12. 2. 20:48

////////////////    util.js   ////////////////////////////////////////

 

//----------------------------------------------------------------- 
// 자바스크립트 디버깅 옵션 
//----------------------------------------------------------------- 
function DEBUG(str) 

debug=false; 
if(debug) 
alert!(str); 

//----------------------------------------------------------------- 
// 날짜 형식을 체크한다.(YYYY-MM-DD) 맞는 형식이면 true 틀린 형식이면 false 
//----------------------------------------------------------------- 
function dateFormat(str) 

isValid=true; 
str=str+""; 
//str=TrimString(str); 

if(str.length !=10) return false; 

if(str.charAt(4)!="-" || str.charAt(7)!="-") return false; 

for( i = 0; i < 4; i++) 

if( str.charAt(i) > "9" || str.charAt(i) < "0" ) 

isValid=false; 
break; 


for( i=5; i<7 ;i++) 

if( str.charAt(i)>9 || str.charAt(i)<0 ) 

isValid=false; 
break; 


for( i=8; i<10 ;i++) 

if( str.charAt(i)>9 || str.charAt(i)<0 ) 

isValid=false; 
break; 


return isValid; 


//----------------------------------------------------------------- 
// 날짜시간를 yyyy-mm-dd hh:mm:ss 형식에 맞게 반환한다. 
//----------------------------------------------------------------- 
function GetDateTime(ParamDateTime) 

var myDate = ParamDateTime; 
var yy, mm, dd; // 날짜 
var ho, mi, se; // 시간 

yy=(myDate.getYear()<100) ? "19" + myDate.getYear() : myDate.getYear(); 
mm = myDate.getMonth() + 1 ; 
mm = (mm < 10) ? "0" + mm : mm; 
dd = myDate.getDate(); 
dd = (dd < 10) ? "0" + dd : dd; 

ho = myDate.getHours(); 
mi = myDate.getMinutes(); 
se = myDate.getSeconds(); 

return (yy + "-" + mm + "-" + dd + " " + LZero(ho,2) + ":" + LZero(mi,2) + ":" + LZero(se,2)); 


//------------------------------------------------------------------ 
// 수치 왼쪽에 0을 채운다 
//------------------------------------------------------------------ 
function LZero(num, cnt) 

var x, y; 
var tmp = ""; 
var tmp2 = num + ""; 

if(tmp2.length >= cnt) return tmp2; 

for(x=0; x<(cnt-tmp2.length); x++) 

tmp = tmp + "0"; 


tmp = tmp + tmp2; 

return tmp; 


//----------------------------------------------------------------- 
// 날짜문자열(yyyy-mm-dd hh:mi:se)를 일련의 초단위로 전환하여 return 한다. 
//----------------------------------------------------------------- 
function GetDateNum(v_date) 

var datenum = v_date; 
var retval = 0; 
var maxDay = 0; 
var monthDays = new Array(12); 

// HOO 
var yyyy = parseInt(datenum.substr(0,4)); 
var mm = Convert_Int(datenum.substr(5,2)); 
var dd = Convert_Int(datenum.substr(8,2)); 
var hh = Convert_Int(datenum.substr(11,2)); 
var min = Convert_Int(datenum.substr(14,2)); 
var sec = Convert_Int(datenum.substr(17,2)); 

isLeapYear = (((yyyy % 4 == 0) && (yyyy % 100 != 0 )) || (yyyy % 400 == 0)); 
monthDays = arrayOfDaysInMonths(isLeapYear); // 해당 달의 마지막 날짜 얻어옴 

maxDay = monthDays[mm-1]; 

retval = (yyyy-1)*365*24*60*60; 

for (var i=1 ; i < mm ; i++){ 
retval = retval + ( monthDays[i-1] ) * 24 * 60 * 60; 



retval = retval + (dd -1)*24*60*60 ; 
retval = retval + sec + (hh*60*60) + (min)*60; 
return retval; 


function Convert_Int(param) 

if(param.charAt(0) == "0") 
param = param.charAt(1); 
param = parseInt(param); 
return param ; 


function arrayOfDaysInMonths(isLeapYear) 

retMon = new Array(12); 

retMon[0] = 31; 

if (isLeapYear) retMon[1] = 29 ; 
else retMon[1] = 28; 

retMon[2] = 31; 
retMon[3] = 30; 
retMon[4] = 31; 
retMon[5] = 30; 
retMon[6] = 31; 
retMon[7] = 31; 
retMon[8] = 30; 
retMon[9] = 31; 
retMon[10] = 30; 
retMon[11] = 31; 

return retMon; 


//----------------------------------------------------------------- 
// 현재 시스템 날짜와 입력받은 날짜의 차이를 날(日)수로 리턴한다. 
// str1 형식은 "YYYY-MM-DD"형식이다. 아니면 ""을 리턴한다. 
//----------------------------------------------------------------- 
function CmpDate(str1,str2) 


if(!dateFormat(str1) ||!dateFormat(str2)) return ""; 

date1 = new Date(); //현재 시스템 날짜 
date2 = new Date(); // 입력받은 날짜 

date1.setYear(str1.substring(0,4)); 
date1.setMonth(str1.substring(5,7)-1); 
date1.setDate(str1.substring(8,10)); 

date2.setYear(str2.substring(0,4)); 
date2.setMonth(str2.substring(5,7)-1); 
date2.setDate(str2.substring(8,10)); 

DEBUG("CmpDate"); 
var v_date1 = GetDateNum(GetDateTime(date1)); // date를 초로 변환 
var v_date2 = GetDateNum(GetDateTime(date2)); 

DEBUG("v_date1 = " + v_date1); 
DEBUG("v_date2 = " + v_date2); 
retVal = v_date1 - v_date2; 

if(retVal != 0) retVal = retVal/(24*60*60); 
else retVal = 0; 
DEBUG("return = " + retVal); 

return retVal; 







<!-- 
/* 
체크된 옵션으로부터 값을 받아온다. 
*/ 
function optCheckedValue(obj){ 
var value; 
this.obj=obj; 
var len=obj.length; 
for(var i=0;i<len;i++){ 
if(obj[i].checked) value=obj[i].value; 
}return value; 


/* 
체크된 옵션으로 부터 인덱스를 받아온다. 
*/ 
function optCheckedIndex(obj){ 
var index; 
this.obj=obj; 
var len=obj.length; 
for(var i=0;i<len;i++){ 
if(obj[i].checked) index=i; 
}return index; 

function findObj(n, d) { //v3.0 
var p,i,x; 
if(!d) d=document; 
if((p=n.indexOf("?"))>0&&parent.frames.length) { 
d=parent.frames[n.substring(p+1)].document; 
n=n.substring(0,p);} 
if(!(x=d[n])&&d.all) x=d.all[n]; 
for (i=0;!x&&i<d.forms.length;i++) 
x=d.forms[i][n]; 
for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
x=findObj(n,d.layers[i].document); 
return x; 


function showHideLayers() { //v3.0 
var i,p,v,obj,args=showHideLayers.arguments; 
for (i=0; i<(args.length-1); i+=2) 
if ((obj=findObj(args[i]))!=null) 
{ v=args[i+1]; 
if (obj.style) { 
obj=obj.style; 
v=(v=='show')?'visible':(v='hide')?'hidden':v; 

obj.visibility=v; 



/* ====================================================================== 
FUNCTION: getCurrentBrowserStr //--> 

INPUT: none. 

RETURN: a string indicating the current browser 

DESC: This function is used with client-side JavaScript to detect 
the brand and version of the user's browser. Detects only 
Netscape and Microsoft browsers. Returns "Other" if a different 
brand is detected. 

PLATFORMS: Netscape Navigator 3.01 and higher, 
Microsoft Internet Explorer 3.02 and higher, 
====================================================================== */ 
function getCurrentBrowserStr() { 
var current_browser = ""; 
var bwr = new String(navigator.appName); 
var ver = parseInt(navigator.appVersion, 10); 

if(ver+"" != "NaN") 

if ( bwr.toUpperCase() == "NETSCAPE" && ver == 5 ) current_browser = "Netscape 5.0"; 
else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 4 ) current_browser = "Netscape 4.0"; 
else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 3 ) current_browser = "Netscape 3.0"; 
else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 2 ) current_browser = "Netscape 2.0"; 
else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 3 ) current_browser = "MSIE 3.0"; 
else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 4 ) current_browser = "MSIE 4.0"; 
else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 5 ) current_browser = "MSIE 5.0"; 
else current_browser = "Other"; 

return current_browser; 
} // end getCurrentBrowserStr 

/* ====================================================================== 
FUNCTION: getCurrentBrowserInt 
INPUT: none. 
RETURN: a integer indicating the index of the current browser 
DESC: This function is used with client-side JavaScript to detect 
the brand and version of the user's browser. Detects only 
Netscape and Microsoft browsers. Returns 0 if a different 
brand is detected. 
PLATFORMS: Netscape Navigator 3.01 and higher, 
Microsoft Internet Explorer 3.02 and higher, 
====================================================================== */ 

function getCurrentBrowserInt() { 
var current_browser = 0; 
var bwr = new String(navigator.appName); 
var ver = parseInt(navigator.appVersion, 10); 

if(ver+"" != "NaN") 

if ( bwr.toUpperCase() == "NETSCAPE" && ver == 5 ) current_browser = 4; 
else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 4 ) current_browser = 3; 
else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 3 ) current_browser = 2; 
else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 2 ) current_browser = 1; 
else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 3 ) current_browser = 5; 
else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 4 ) current_browser = 6; 
else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 5 ) current_browser = 7; 
else current_browser = 0; 


return current_browser; 
} // end getCurrentBrowserInt 
//--> 
/* ====================================================================== 
FUNCTION: getCurrentBrowser 

INPUT: none. 

RETURN: none. 

DESC: This function is used with client-side JavaScript to detect 
the brand and version of the user's browser. Detects only 
Netscape and Microsoft browsers. 

PLATFORMS: Netscape Navigator 3.01 and higher, 
Microsoft Internet Explorer 3.02 and higher, 
====================================================================== */ 

function getCurrentBrowser() { 
var bwr = new String(navigator.appName); 
var ver = parseInt(navigator.appVersion, 10); 

if(ver+"" != "NaN") 

if ( bwr.toUpperCase() == "NETSCAPE" && ver == 5 ) { 
if(this.onNS+"" != "null") 
this.onNS(); 
if(this.onNS5+"" != "null") 
this.onNS5(); 

else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 4 ) { 
if(this.onNS+"" != "null") 
this.onNS(); 
if(this.onNS4+"" != "null") 
this.onNS4(); 

else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 3 ) { 
if(this.onNS+"" != "null") 
this.onNS(); 
if(this.onNS3+"" != "null") 
this.onNS3(); 

else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 2 ) { 
if(this.onNS+"" != "null") 
this.onNS(); 
if(this.onNS2+"" != "null") 
this.onNS2(); 

else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 3 ) { 
if(this.onIE+"" != "null") 
this.onIE(); 
if(this.onIE3+"" != "null") 
this.onIE3(); 

else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 4 ) { 
if(this.onIE+"" != "null") 
this.onIE(); 
if(this.onIE4+"" != "null") 
this.onIE4(); 

else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 5 ) { 
if(this.onIE+"" != "null") 
this.onIE(); 
if(this.onIE5+"" != "null") 
this.onIE5(); 

else { 
if(this.onOther+"" != "null") 
this.onOther(); 



} // end getCurrentBrowser 

function getCookie(name){ 
var cname = name +"="; 
var dc = document.cookie! 

if(dc.length>0){ 
begin = dc.indexOf(cname); 
if(begin!=-1){ 
begin += cname.length; 
end = dc.indexOf(";",begin); 
if(end == -1) end = dc.length; 
return unescape(dc.substring(begin,end)); 


return null; 


function setCookie(name,value,expires){ 
document.cookie! = name + "=" + escape(value) + ";path=/" + 
((expires == null)?"":"expires=" + expires.toGMTString()); 


function delCookie(name){ 
document.cookie! = name + "=;expires = Thu,01-Jan-70 00:00:01 GMT" + ";path=/"; 


function setValue(element){ 
setCookie(element.name,element.value); 



function getValue(element){ 
var value = getCookie(element.name); 
if(value != null) element.value = value; 

 

 

 

////////////////    validation.js   ////////////////////////////////////////

 

 

 

/* ====================================================================== 

용 도 : 사용자 입력란의 validation check 

====================================================================== */ 

/* ====================================================================== 

FUNCTION: Fix. 소숫점 자리수 지정 . 
입력되는 값은 숫자이어야 한다. . 

====================================================================== */ 
function Fix(myVal, decPlaces) { 
var newVal = myVal 
var returnVal = 0; 

var test = (Math.round(myVal*Math.pow(10,decPlaces))).toString() //Math.round(myVal*Math.pow(10,decPlaces))/Math.pow(10,decPlaces) 
if (decPlaces > 0) 
returnVal = test.substring(0,test.length-decPlaces) + "." + test.substring(test.length-decPlaces,test.length); 
else if (decPlaces == 0) 
returnVal = test.substring(0,test.length-decPlaces); 
else 
returnVal = myVal; 
alert!(returnVal); 
return returnVal; 
} // END Fix 

/* ====================================================================== 
FUNCTION: IsAlpah 
RETURN: 알파벳으로만 이루어져야 true 
====================================================================== */ 
function IsAlpha( str ) { 

if (str+"" == "undefined" || str+"" == "null" || str+"" == "") 
return false; 

var isValid = true; 

str += ""; // convert to a string for performing string comparisons. 

// Loop through string one character at time, breaking out of for 
// loop when an non Alpha character is found. 
for (i = 0; i < str.length; i++) { 
// Alpha must be between "A"-"Z", or "a"-"z" 
if ( !( ((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) || 
((str.charAt(i) >= "A") && (str.charAt(i) <= "Z")) ) ) { 
isValid = false; 
break; 

} // end for loop 
return isValid; 
} // end IsAlpha 

/* ====================================================================== 
FUNCTION: IsAlphaNum 
RETURN: 숫자 또는 알파벳만으로 이루어져야 true 
====================================================================== */ 
function IsAlphaNum( str ) { 
// Return immediately if an invalid value was passed in 
if (str+"" == "undefined" || str+"" == "null" || str+"" == "") 
return false; 

var isValid = true; 

// convert to a string for performing string comparisons. 
str += ""; 

// Loop through length of string and test for any alpha numeric 
// characters 
for (i = 0; i < str.length; i++) 

// Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z" 
if (!(((str.charAt(i) >= "0") && (str.charAt(i) <= "9")) || 
((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) || 
((str.charAt(i) >= "A") && (str.charAt(i) <= "Z")))) 

isValid = false; 
break; 

} // END for 

return isValid; 
} // end IsAlphaNum 

/* ====================================================================== 
FUNCTION: IsAlphaNumOrUnderscore 
RETURN: 숫자와 알파벳 그리고 '_'만을 포함하면 true 
====================================================================== */ 
function IsAlphaNumOrUnderscore( str ) { 
// Return immediately if an invalid value was passed in 
if (str+"" == "undefined" || str+"" == "null" || str+"" == "") 
return false; 

var isValid = true; 

str += ""; // convert to a string for performing string comparisons. 
// Loop through string one character at a time. If non-alpha numeric 
// is found then, break out of loop and return a false result 

for (i = 0; i < str.length; i++) 

// Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z" 
if ( !( ((str.charAt(i) >= "0") && (str.charAt(i) <= "9")) || 
((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) || 
((str.charAt(i) >= "A") && (str.charAt(i) <= "Z")) || 
(str.charAt(i) == "_") ) ) 

isValid = false; 
break; 


} // END for 

return isValid; 

} // end IsAlphaNumOrUnderscore 

/* ====================================================================== 
FUNCTION: IsInt 
RETURN: 0-9 사이 정수만 포함되어야 true 
allowNegatives가 true일경우 '-'로 시작하는 정수는 true 
====================================================================== */ 
function IsInt( numstr, allowNegatives ) { 
// Return immediately if an invalid value was passed in 
if (numstr+"" == "undefined" || numstr+"" == "null" || numstr+"" == "") 
return false; 

// Default allowNegatives to true when undefined or null 
if (allowNegatives+"" == "undefined" || allowNegatives+"" == "null") 
allowNegatives = true; 

var isValid = true; 

// convert to a string for performing string comparisons. 
numstr += ""; 

// Loop through string and test each character. If any 
// character is not a number, return a false result. 
// Include special case for negative numbers (first char == '-'). 
for (i = 0; i < numstr.length; i++) { 
if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9") || (numstr.charAt(i) == "-"))) { 
isValid = false; 
break; 
} else if ((numstr.charAt(i) == "-" && i != 0) || 
(numstr.charAt(i) == "-" && !allowNegatives)) { 
isValid = false; 
break; 


} // END for 

return isValid; 
} // end IsInt 

/* ====================================================================== 
FUNCTION: IsValidYear 
RETURN: 날짜형태인지 체크후 boolean 리턴 
CALLS: IsInt() 
====================================================================== */ 
function IsValidYear(year){ 

var isValid=false; 
today = new Date(); 
//if(!IsBlank(year)){ 
if(IsInt(year)){ 
if(year.length==4 && (year.charAt(0)==1 || year.charAt(0)==2) && (year.charAt(1)==0 || year.charAt(1)==9)){ 
if(year>1000) isValid = true; 


//} 
return isValid; 




/* ====================================================================== 
FUNCTION: IsNum 
RETURN: 숫자면 true, 부동형,negative형 인정 
====================================================================== */ 
function IsNum( numstr ) { 
// Return immediately if an invalid value was passed in 
if (numstr+"" == "undefined" || numstr+"" == "null" || numstr+"" == "") 
return false; 

var isValid = true; 
var decCount = 0; // number of decimal points in the string 

// convert to a string for performing string comparisons. 
numstr += ""; 

// Loop through string and test each character. If any 
// character is not a number, return a false result. 
// Include special cases for negative numbers (first char == '-') 
// and a single decimal point (any one char in string == '.'). 
for (i = 0; i < numstr.length; i++) { 
// track number of decimal points 
if (numstr.charAt(i) == ".") 
decCount++; 

if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9") || 
(numstr.charAt(i) == "-") || (numstr.charAt(i) == "."))) { 
isValid = false; 
break; 
} else if ((numstr.charAt(i) == "-" && i != 0) || 
(numstr.charAt(i) == "." && numstr.length == 1) || 
(numstr.charAt(i) == "." && decCount > 1)) { 
isValid = false; 
break; 

//if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9")) || 
} // END for 

return isValid; 
} // end IsNum 
/* ====================================================================== 
FUNCTION: IsValid5DigitZip 
RETURN: 6자리 숫자로만 입력된 우편번호면 true 
CALLS: IsBlank(), IsInt() 
====================================================================== */ 
function IsValid6DigitZip( str ) { 
// Return immediately if an invalid value was passed in 
if (str+"" == "undefined" || str+"" == "null" || str+"" == "") 
return false; 

var isValid = true; 

str += ""; 
if (IsBlank(str) || (str.length != 6) || !IsInt(str, false)) 
isValid = false; 

return isValid; 
} // end IsValid6DigitZip 
/* ====================================================================== 
FUNCTION: IsValid3Plus3DigitZip 
RETURN: 숫자 3자리 '-' 숫자 3자리 형태의 우편번호면 true 
CALLS: IsBlank(), IsInt() 
====================================================================== */ 
function IsValid3Plus3DigitZip( str ) { 
// Return immediately if an invalid value was passed in 
if (str+"" == "undefined" || str+"" == "null" || str+"" == "") 
return false; 

var isValid = true; 

str += ""; 

if (IsBlank(str) || (str.length != 7) || 
!IsInt(str.substring(0,2), false) || str.charAt(3) != '-' || 
!IsInt(str.substring(4,6), false)) 
isValid = false; 
return isValid; 
} // end IsValid3Plus3DigitZip 

/* ====================================================================== 
FUNCTION: IsValidEmail 
RETURN: 올바른 email포맷이면 true 
CALLS: IsBlank(), IsAlpha() 
====================================================================== */ 
function IsValidEmail( str ) { 
// Return immediately if an invalid value was passed in 
if (str+"" == "undefined" || str+"" == "null" || str+"" == "") 
return false; 

var isValid = true; 

str += ""; 

namestr = str.substring(0, str.indexOf("@")); // everything before the '@' 
domainstr = str.substring(str.indexOf("@")+1, str.length); // everything after the '@' 

// Rules: namestr cannot be empty, or that would indicate no characters before the '@', 
// domainstr must contain a period that is not the first character (i.e. right after 
// the '@'). The last character must be an alpha. 
if (IsBlank(str) || (namestr.length == 0) || 
(domainstr.indexOf(".") <= 0) || 
(domainstr.indexOf("@") != -1) || 
!IsAlpha(str.charAt(str.length-1))) 
isValid = false; 

return isValid; 
} // end IsValidEmail 
/* ====================================================================== 
FUNCTION: IsValidPhone 
RETURN: 국번이 없을경우는 incAreaCode를 false로 두거나 생략하고 
7자리의 숫자로만 이루어져야 true 
국번이 있을경우 incAreaCodes는 true로 두고 
9자리나 10자리의 숫자로만 이루어져야 true 
CALLS: StripNonNumeric() 
====================================================================== */ 
function IsValidPhone( str, incAreaCode ) { 
// Return immediately if an invalid value was passed in 
if (str+"" == "undefined" || str+"" == "null" || str+"" == "") 
return false; 

// Set default value for incAreaCode to false, if undefined or null 
if (incAreaCode+"" == "undefined" || incAreaCode+"" == "null") 
incAreaCode = false; 

var isValid = true; 

str += ""; 

// After stripping out non-numeric characters, such as dashes, the 
// phone number should contain 7 digits (no area code) or 10 digits (area code) 
str = StripNonNumeric(str+""); 
if (incAreaCode && (str.length ==9 || str.length ==10)) 
isValid = true; 
else isValid=false; 


if (!incAreaCode && str.length != 7) 
isValid = false; 
alert!(isValid);alert!(str.length); 
return isValid; 
} // end IsValidPhone 
/* ====================================================================== 
FUNCTION: IsValidSSN 
RETURN: true, if the string contains digits and dashes in the form 111-12-3456; 
true, if the string contains a 9-digit number and incDashes is false; 
false, otherwise 
CALLS: IsInt() 
====================================================================== */ 
function IsValidSSN( str, incDashes ) { 
// Return immediately if an invalid value was passed in 
if (str+"" == "undefined" || str+"" == "null" || str+"" == "") 
return false; 

var isValid = true; 

// Set default value for incDashes to true, if undefined or null 
if (incDashes+"" == "undefined" || incDashes+"" == "null") 
incDashes = true; 

str += ""; // make sure it's a string 

if (!incDashes && (!IsNum(str) || str.length != 9)) 
isValid = false; 

var part1 = str.substring(0,3); 
var part2 = str.substring(4,6); 
var part3 = str.substring(7,str.length); 

// Ensure that the first part is a number and 3 digits long, 
// the second part is a number and 2 digits long, 
// the third part is a number and 4 digits long, e.g. 111-22-3333 
if (incDashes && ((!IsInt(part1, false) || part1.length != 3) || 
(!IsInt(part2, false) || part2.length != 2) || 
(!IsInt(part3, false) || part3.length != 4)) ) 
isValid = false; 

return isValid; 
} // end IsValidSSN 


/* ====================================================================== 
FUNCTION: IsBlank 
RETURN: 문자가 null, undefined 이거나 공백 "" 미면 true 
false, otherwise. 
CALLS: IsNull(), IsUndef() 
====================================================================== */ 
function IsBlank( str ) { 
var isValid = false; 

if ( IsNull(str) || IsUndef(str) || (str+"" == "") ) 
isValid = true; 

return isValid; 
} // end IsBlank 
/* ====================================================================== 
FUNCTION: IsNull 
RETURN: 값이 null이면 true 
====================================================================== */ 
function IsNull( val ) { 
var isValid = false; 

if (val+"" == "null") 
isValid = true; 

return isValid; 
} // end IsNull 
/* ====================================================================== 
FUNCTION: IsUndef 
RETURN: 값이 undefined면 true 
====================================================================== */ 
function IsUndef( val ) { 
var isValid = false; 

if (val+"" == "undefined") 
isValid = true; 

return isValid; 
} // end IsUndef 

/* ====================================================================== 
FUNCTION: StripNonNumeric 
RETURN: 0-9 사이의 숫자만 추출하여 스트링으로 리턴; 
잘못된 입력은 null 리턴 
====================================================================== */ 
function StripNonNumeric( str ) { 
var resultStr = ""; 

// Return immediately if an invalid value was passed in 
if (str+"" == "undefined" || str == null) 
return null; 

// Make sure the argument is a string 
str += ""; 

// Loop through entire string, adding each character from the original 
// string if it is a number 
for (var i=0; i < str.length; i++) 

if ( (str.charAt(i) >= "0") && (str.charAt(i) <= "9") ) 
resultStr = resultStr + str.charAt(i); 

} // end for loop 
return resultStr; 
} // end StripNonNumeric 


/* ====================================================================== 
FUNCTION: DetermineCurrentBrowser 
RETURN: 현재브라우저의 종류 
====================================================================== */ 
function DetermineCurrentBrowser() { 
var current_browser = ""; 
var bwr = navigator.appName; 
var ver = parseInt(navigator.appVersion, 10); 

if ( bwr == "Netscape" && ver == 4 ) current_browser = "Netscape 4.0"; 
else if ( bwr == "Netscape" && ver == 3 ) current_browser = "Netscape 3.0"; 
else if ( bwr == "Netscape" && ver == 2 ) current_browser = "Netscape 2.0"; 
else if ( bwr == "Microsoft Internet Explorer" && ver == 3 ) current_browser = "MSIE 3.0"; 
else if ( bwr == "Microsoft Internet Explorer" && ver == 4 ) current_browser = "MSIE 4.0"; 
else current_browser = "Other"; 

return current_browser; 
} // end DetermineCurrentBrowser 

/* ====================================================================== 
FUNCTION: viewObject 
INPUT: obj (object): 볼 오브젝트 
objName (string): 오브젝트 명the name of the object that corresponds to obj 
RETURN: A string containing HTML showing the list of object properties; 
returns null if invalid arguments were passed 
DESC: This function loops through any JavaScript/JScript object and 
and returns HTML that will display all properties of the object 
between two HTML horizontal rules. 
====================================================================== */ 
function viewObject (obj, objName) { 
var outputStr = ""; 

// Return immediately if an invalid value was passed in 
if (obj+"" == "undefined" || obj+"" == "null") 
return null; 
// Set default object name if none is provided 
if (objName+"" == "undefined" || objName+"" == "null") 
objName = "[Object]"; 

outputStr = "<BR><HR><BR>\n"; 
outputStr += "\n<BR><B>"+objName+" Properties: </B><BR>"; 
for (prop in obj) { 
outputStr += "\n<BR>"+objName+"."+prop+" = "+obj[prop]; 

outputStr += "<BR><HR><BR>\n"; 
document.writeln(outputStr); 
return outputStr; 
} // end viewObject 

/* ====================================================================== 
FUNCTION: IsIdValid 
DESC: 주민번호체크 
RETURN: boolean 
====================================================================== */ 

function IsIdValid(jumin){ 
var j=9 
var id_chk=0 
tmp = false; 
var str=jumin; 
object = new Array(13) 
for(var i=0;i < 13;i++) { 
object[i] = str.substring(i,i+1) 

var chkdigit = str.substring(12, 13) 
for(var i=0;i < 12;i++){ 
if( i == 8 ) 
j = 9 
object[i]=object[i]*j 
j-- 
id_chk +=object[i] 

if(((id_chk%11 == 0) && (chkdigit == 1)) || ((id_chk%11 ==10)&& (chkdigit ==0))){ 
return 1; 

else if((id_chk %11 != 0) && (id_chk % 11 != 10 ) && (id_chk % 11 == chkdigit)){ 
return 1; 

else{ 
return 0; 




/* ====================================================================== 
FUNCTION: IsBupinId 
DESC: 법인번호를 검사한다 
RETURN: boolean 
====================================================================== */ 

function IsBupinId(str) 

var check = 1; 
var no = new Array(13); 
var sum = 0; 
var rem = 0; 
var m = 0; 

if(IsBlank(str)) return false; 

m = parseInt(str.charAt(12)); // 번호의 마지막 숫자 얻기 

for(var i=0; i<12; i++) no[i] = parseInt(str.charAt(i)); // 1~12까지 숫자 얻기 

for(var i=0; i<12; i++) { 
sum += (check * no[i]); 

check = (check==1) ? 2 : 1; 


rem = sum % 10; // 나머지 구하기 

rem = 10 - rem; 

rem = (rem >= 10) ? rem - 10 : rem; 

// 마지막번째와 10-rem의 값을 비교 

if(m == rem) return true; // 정확 
else return false; // 부정확 


/* ====================================================================== 
FUNCTION: IsSaupId 
DESC: 사업자등록번호를 검사한다 
RETURN: boolean 
====================================================================== */ 
function IsSaupId(str) 

var check = 0; 
var no = new Array(10); 
var sum = 0; 
var tmpNo = 0; 
var tmpStr = 0; 

if(IsBlank(str)) return false; 

for(var i=0; i<10; i++) no[i] = parseInt(str.charAt(i)); // 1~10까지 숫자 얻기 

for(var i=0; i<10; i++) { 
if((i%3)==0) 
tmpNo = no[i] + 0; 
else if ( (i%3) == 1) 
tmpNo = no[i] * 3; 
else if ( (i%3) == 2) 
tmpNo = no[i] * 7; 

if(i==8) 

tmpNo = no[i] * 5; 

if(tmpNo > 9) { 
tmpStr = tmpNo + ""; 
tmpNo = parseInt(tmpStr.charAt(0)) + parseInt(tmpStr.charAt(1)); 



sum += tmpNo; 


if( (sum % 10) == 0) return true; // 정확 
else return false; // 부정확 



/* ====================================================================== 
FUNCTION: AgeCal 
DESC: 주민번호로부터 나이계산 
RETURN: 나이 
====================================================================== */ 

function AgeCal(jumin1, str) 
{ //나이계산하는 함수 
// today = new Date(); 

var toyy = document.hiddenform.toYear.value; 
var tomm = document.hiddenform.toMonth.value; 
var todd = document.hiddenform.curDate.value; 


var datechk = false; 
//if (toyy < 50 ) 
// toyy = 100 + eval!(toyy); 
var juyy = eval!(jumin1.substring(0,2)); 
var jumm = eval!(jumin1.substring(2,4)); 
var judd = eval!(jumin1.substring(4,6)); 
var juwm = eval!(str); 

if(juwm==1||juwm==2) 
juyy = juyy + 1900; 
if(juwm==3||juwm==4) 
juyy = juyy + 2000; 

if (((tomm ==1 || tomm == 3 || tomm == 5 || tomm==7 || tomm ==8 || tomm == 10 || tomm == 12 ) && todd == 31) || ((tomm ==4 || tomm ==6 || tomm == 9 || tomm == 11) && todd==30 ) || (tomm == 2 && (todd==28 || todd == 29 ))) 
datechk = true; 
var caldd = eval!(todd) - eval!(judd); 
if ( caldd < 0 && datechk == false) 
tomm = tomm - 1 
var calmm = eval!(tomm) - eval!(jumm); 
if (calmm < 0 ) { 
toyy = toyy - 1 ; 
calmm = calmm + 12; 

calyy = eval!(toyy) - eval!(juyy); 
if (calmm > 5 ) 
calyy = calyy + 1; 
// alert!("calyy : " + calyy); 
return calyy; 



/* ====================================================================== 
FUNCTION: getSex 
DESC: 주민번호 뒤자리로 성별 가져오기 
RETURN: 남자 "1", 여자 "2" 
====================================================================== */ 
function getSex(str){ 

if(str.substring(0, 1)%2 != 0 ) return 1; 
if(str.substring(0, 1)%2 == 0 ) return 2; 


////////////////////////////////////////////////////////////////////////////////////////////////// 
//str은 key를 포함한 문자열, key는 문자열을 나누는 문자, num은 나눈 나머지의 문자열 의 num째 문자열 리턴 
function cutoffString(str, key, num){ 
var UsrString; 
UsrString = str; 

var usrArray = UsrString.split(key); 
return usrArray[num-1]; 


/* ====================================================================== 
FUNCTION: makeBirth 
DESC: 주민번호 처음 6자리로 생년월일 만들기 
RETURN: 
====================================================================== */ 

function makeBirth(str){ 
var birthday = ""; 
var tmp = ""; 

tmp = str.substring(6, 7); 
if( tmp > 2 ) birthday = "20" + str.substring(0, 2); 
else birthday = "19" + str.substring(0, 2); 
birthday += "/" + str.substring(2,4); 
birthday += "/" + str.substring(4,6); 

return birthday; 


/* ====================================================================== 
FUNCTION: checkBirth , LeafYearCheck 
DESC: 19000909형태의 4자리연도 2자리월 2자리일의 형식이 
올바른지 체크 
RETURN: boolean 
====================================================================== */ 

function checkBirth(str){ 
var valid = true; 
var msg=""; 
var birth = str; 
var yyyy = birth.substring(0,4); 
var mm = birth.substring(4,6); 
var dd = birth.substring(6,8); 
var months = new Array("", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"); 

if ((IsBlank(birth) || birth.length != 8) || !IsInt(birth, false)){ 
msg+="예)19700101\n"; 
valid= false; 
return valid; 

if(!(yyyy.substring(0,2)=="19" || yyyy.substring(0,2)=="20")){ 
msg+="년도입력오류!\n"; 
valid= false; 


if(mm>12 || mm<1){ 
msg+="월입력오류!(1~12)\n"; 
valid = false; 


if ((mm != 02) && (mm == 04 || mm == 06 || mm == 09 || mm == 11) && dd > 30) { 
msg+= months[mm] + "월의 마지막 날은 30일 입니다.\n"; 
valid = false; 
}else if ((mm != 02) && (dd > 31)) { 
msg+= months[mm] + "월의 마지막 날은 31일 입니다.\n"; 
valid = false; 


if(mm == 02) 

var leap; 
leap = LeafYearCheck(yyyy); 
if(leap == true && dd > 29) 

msg+= yyyy + "년의 2월은 29일 까지 있습니다."; 
valid = false; 

else if(leap == false && dd > 28) 

msg+= yyyy + "년의 2월은 28일 까지 있습니다."; 
valid = false; 



if(dd>31 || dd<1){ 
msg+="일입력오류!(1~31)\n"; 
valid= false; 

if(valid==false){ 
alert!(msg); 

return valid; 


function LeafYearCheck(yyyy) 

if((yyyy % 4) == 0) 

if((yyyy % 100) == 0) 

if((yyyy % 400) == 0) return true; 
else return false; 

else return true; 


return false; 

/* ====================================================================== 
FUNCTION: getCurrentBrowserStr 

INPUT: none. 

RETURN: a string indicating the current browser 

DESC: This function is used with client-side JavaScript to detect 
the brand and version of the user's browser. Detects only 
Netscape and Microsoft browsers. Returns "Other" if a different 
brand is detected. 

====================================================================== */ 
function getCurrentBrowserStr() { 

var current_browser = ""; 
var bwr = new String(navigator.appName); 
var ver = parseInt(navigator.appVersion, 10); 

if(ver+"" != "NaN") 

if ( bwr.toUpperCase() == "NETSCAPE" && ver == 5 ) current_browser = "Netscape 5.0"; 
else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 4 ) current_browser = "Netscape 4.0"; 
else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 3 ) current_browser = "Netscape 3.0"; 
else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 2 ) current_browser = "Netscape 2.0"; 
else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 3 ) current_browser = "MSIE 3.0"; 
else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 4 ) current_browser = "MSIE 4.0"; 
else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 5 ) current_browser = "MSIE 5.0"; 
else current_browser = "Other"; 

return current_browser; 
} // end getCurrentBrowserStr 

/* ====================================================================== 
FUNCTION: IsDotAndInt 
RETURN: 0-9 사이 정수와 맨앞과 맨뒤를 제외한 위치의 마침표로 
이루어지면 true 
====================================================================== */ 
function IsDotAndInt(str) { 

if (str+"" == "undefined" || str+"" == "null" || str+"" == "") 
return true; 
var isValid = true; 


str += ""; 

for (i = 0; i < str.length; i++) { 
if (!((str.charAt(i) >= "0") && (str.charAt(i) <= "9") || (str.charAt(i) == "."))) { 
isValid = false; 
break; 
} else if (str.charAt(i) == "." && (i == 0 || i == str.length)) { 
isValid = false; 
break; 


} // END for 

return isValid; 

/* ====================================================================== 
FUNCTION: IsCommaAndInt 
RETURN: 0-9 사이 정수와 맨앞과 맨뒤를 제외한 위치의 콤마로 
이루어지면 true 
====================================================================== */ 
function IsCommaAndInt(str) { 

if (str+"" == "undefined" || str+"" == "null" || str+"" == "") 
return true; 
var isValid = true; 


str += ""; 

for (i = 0; i < str.length; i++) { 
if (!((str.charAt(i) >= "0") && (str.charAt(i) <= "9") || (str.charAt(i) == ","))) { 
isValid = false; 
break; 
} else if (str.charAt(i) == "," && (i == 0 || i == str.length)) { 
isValid = false; 
break; 


} // END for 

return isValid; 

/* ====================================================================== 
FUNCTION: IsCommaAndAge 
RETURN: 특정나이(age) 이하의 나이와 맨앞과 맨뒤를 제외한 위치의 콤마로 
이루어지면 true 
====================================================================== */ 
function IsCommaAndAge(agestr,age){ 
var valid = true; 
var temp = true; 

if(IsCommaAndInt(agestr)){ 
var tokens = agestr.split(","); 
for(i=0;i<tokens.length;i++){ 

if(!IsBlank(tokens[i])){ 
if(tokens[i] < 0 || parseInt(tokens[i]) > age) { 
temp = false; 


if(temp==false) valid = false; 

}else{ 
valid = false; 

return valid; 


/* ====================================================================== 
FUNCTION: TrimString 
RETURN: String속의 스페이스를 삭제한후 String을 리턴 
====================================================================== */ 

function TrimString(str){ 
var rtnStr=""; 
for(i=0;i<str.length;i++){ 
if(str.charAt(i) != " "){ 
rtnStr = rtnStr +str.charAt(i); 


return rtnStr; 

/* ====================================================================== 
FUNCTION: IsNum2 
RETURN: 정수이면(0~9) true 아니면 false -부동형,음수 불인정 
작성자 : 고원택 
====================================================================== */ 
function IsNum2( numstr ) 

var isValid = true; 

// Return immediately if an invalid value was passed in 
if (numstr+"" == "undefined" || numstr+"" == "null" || numstr+"" == "") 
return false; 

// convert to a string for performing string comparisons. 
numstr += ""; 

for (i = 0; i < numstr.length; i++) 

if (numstr.charAt(i) <"0" ||numstr.charAt(i)> "9" ) 

isValid = false; 
break; 



return isValid; 


/* ====================================================================== 
FUNCTION: 전화번호를 체크한다. 
RETURN: 지역번호/국번/번호 타입이면 true, 아니면 false 
====================================================================== */ 
function IsValidTel(str){ 

str = TrimString(str); //str안의 space를 모두 없앤다. 

if(IsBlank(str)){ return false; } 

var myToken = new Token(str, "-/,)");//지정된 문자를 seq을 참고해 Token으로 만든다. 

if(myToken.length != 3){ 
return false; 
}else{//Token이 3개일 경우만(지역번호,국번,번호) 

for(j = 0; j < 3; j++){ 
var numstr = myToken[j]; 
if(numstr.length>4) return false; 
if(!IsInt(numstr)) return false; 

}//end for 
}//end if 

return true; 

/* ====================================================================== 
FUNCTION: 전화번호를 신보포맷으로 리턴한다.. 
RETURN: 지역번호/국번/번호 
ex) 02)213-2331 ==> '02 213 2331'의 12(4+4+4)자리 스트링 리턴 
위의 IsValidTel(str)에 의해 검증된 데이타만 넘길것 
====================================================================== */ 
function shinboTelFormat( str ) { 
var resultStr = ""; 

str += ""; 
str = TrimString(str); //str안의 space를 모두 없앤다. 
var myToken = new Token(str, "-"); //지정된 문자를 seq을 참고해 Token으로 만든다. 

for(t=0;t<myToken.length;t++){ 
if(myToken[t].length<4){ 
for(m=0;4-myToken[t].length;m++){ 
myToken[t]+=" "; 


resultStr+=myToken[t]; 

return resultStr; 


//-------------------------------------------------------------- 
// str으로 지정된 문자열을 문자열 seps의 문자들을 참고하여 
// Token으로 만들어 배열로 반환한다. 
// 
// ex) var myToken = new Token("aa-bb,cc dd. ee\nff", "-, .\n") 
// myToken.length := 6 
// myToken[0] := "aa" 
// myToken[1] := "bb" 
// myToken[2] := "cc" 
// myToken[3] := "dd" 
// myToken[4] := "ee" 
// myToken[5] := "ff" 
// 


function Token(str, seps) 

var i; 
var start = -1; 
var end = -1; 
var num = 0; 

i = 0; 

do 

for(; i<str.length; i++) // 토큰의 시작위치를 찾는다. 

if(seps.indexOf(str.charAt(i), 0) == -1) // 해당문자가 패턴에 없을 경우 시작위치 지정 

start = i; 
break; 



for(; i<str.length; i++) 

if(seps.indexOf(str.charAt(i), 0) == -1) // 해당문자가 패턴에 없을 경우 위치 지정 

end = i; 

else 

end = (end == -1) ? start : end; 
break; 




// 저장 

num++; 
this.length = num; 
this[num-1] = str.substr(start, (end-start+1)); 


// 시작위치 지정 

start = end = -1; 


} while(i < str.length); 

return this; 







//=============================================== 
// 날짜 관련 함수 Start 
//=============================================== 
/** ============================================= 
Return : String (YYYYMMDD) 
Comment: 현재날자를 구한다 (문자:YYYYMMDD) 
Usage : 
---------------------------------------------- */ 
function fn_getDateNowToStr() 

var dNow = new Date(); 
var yyyy = ""; 
var mm = ""; 
var dd = ""; 

yyyy = dNow.getYear(); 
mm = dNow.getMonth()+1; 
dd = dNow.getDate(); 

yyyy = fn_setFillzeroByVal( yyyy, 4 ); 
mm = fn_setFillzeroByVal( mm, 2 ); 
dd = fn_setFillzeroByVal( dd, 2 ); 
return (yyyy + mm + dd); 

//=============================================== 

/** ============================================= 
Return : String (YYYYMMDD) 
Comment: 현재날자와 시간을를 구한다 (문자:YYYYMMDD hhmmss) 
Usage : 
---------------------------------------------- */ 
function fn_getDateTimeNowToStr() 

var dNow = new Date(); 
var yyyy = ""; 
var MM = ""; 
var dd = ""; 
var hh = ""; 
var mm = ""; 
var sss = ""; 

yyyy = dNow.getYear(); 
MM = dNow.getMonth()+1; 
dd = dNow.getDate(); 
hh = dNow.getHours(); 
mm = dNow.getMinutes(); 
sss = dNow.getSeconds(); 

yyyy = fn_setFillzeroByVal( yyyy, 4 ); 
MM = fn_setFillzeroByVal( MM, 2 ); 
dd = fn_setFillzeroByVal( dd, 2 ); 
hh = fn_setFillzeroByVal( hh, 2 ); 
mm = fn_setFillzeroByVal( mm, 2 ); 
sss = fn_setFillzeroByVal( sss, 2 ); 

return (yyyy + MM + dd + hh + mm + sss); 

//=============================================== 

/** ============================================= 
Return : boolean 
Comment: 입력받은 년도가 윤년이면 true 
Usage : 
---------------------------------------------- */ 
function fn_isLeafYear(YYYY) 

if ( ( (YYYY%4 == 0) && (YYYY%100 != 0) ) || (YYYY%400 == 0) ) { 
return true; 

return false; 

//=============================================== 


/** ============================================= 
Return : int (해당 년,월의 날수) 
Comment: 입력받은 년,월의 최대 일을 구한다. 
Usage : 
---------------------------------------------- */ 
function fn_MaxdayYearMonth(yyyy, mm) 

var monthDD = new Array(31,28,31,30,31,30,31,31,30,31,30,31); 

var iMaxDay = 0; 

if ( fn_isLeafYear(yyyy) ) { 
monthDD[1] = 29; 

iMaxDay = monthDD[mm - 1]; 

return iMaxDay; 

//=============================================== 


/** ============================================= 
Return : boolean 
Comment: 날짜 유효성 체크(분리된 yyyy, mm, dd 값) 
Usage : 
---------------------------------------------- */ 
function fn_isYearMonthDay(yyyy, mm, dd) 

var isTrue = false; 

var iMaxDay = fn_MaxdayYearMonth(yyyy, mm); 

if ( yyyy == "" && mm == "" && dd == "" ) { 
isTrue = true; 
} else { 
if ( (yyyy >= 1901) && (yyyy <= 9999) && 
(mm >= 1) && (mm <= 12) && 
(dd >= 1) && (dd <= iMaxDay) ) 
isTrue = true; 


return isTrue; 

//=============================================== 


/** ============================================= 
Return : boolean 
Comment: 날짜 유효성 체크(병합된 yyyymmdd 값) 
Usage : 
---------------------------------------------- */ 
function fn_isDate(yyyymmdd) 

var isTrue = false; 

if ( yyyymmdd.length == 8 && fn_isNumStr(yyyymmdd) ) { 

var yyyy = eval!(yyyymmdd.substring(0,4)); 
var mm = eval!(yyyymmdd.substring(4,6)); 
var dd = eval!(yyyymmdd.substring(6,8)); 

if ( fn_isYearMonthDay(yyyy,mm,dd) ) 
isTrue = true; 
} else if (yyyymmdd == "") { 
isTrue = true; 


return isTrue; 

//=============================================== 


/** ============================================= 
Return : boolean 
Comment: 날짜 유효성 체크(분리된 objYear, objMonth, objDay 객체) ;; 유효한 경우 각 객체의 값 설정(년도: 4자리, 월/일: 2자리) 
Usage : 
---------------------------------------------- */ 
function fn_isDateByObj(objYear, objMonth, objDay) 

var isTrue = false; 

isTrue = fn_isYearMonthDay(objYear.value, objMonth.value, objDay.value); 

if ( isTrue && objYear.value != "" && objMonth.value != "" && objDay.value != "") { 
objYear.value = fn_setFillzeroByVal(objYear.value, 4); 
objMonth.value = fn_setFillzeroByVal(objMonth.value, 2); 
objDay.value = fn_setFillzeroByVal(objDay.value, 2); 


return isTrue; 

//=============================================== 


/** ============================================= 
Return : boolean 
Comment: 날짜 유효성 체크(분리된 sYearObjName, sMonthObjName, sDayObjName 객체이름) 
Usage : 
---------------------------------------------- */ 
function fn_isDateByObjName(sYearObjName, sMonthObjName, sDayObjName) 

var isTrue = false; 

objYear = getObj(sYearObjName); 
objMonth = getObj(sMonthObjName); 
objDay = getObj(sDayObjName); 

isTrue = fn_isYearMonthDay(objYear.value, objMonth.value, objDay.value); 

return isTrue; 

//=============================================== 


/** ============================================= 
Return : boolean 
Comment: 년월 유효성 체크(분리된 objYear, objMonth 객체) ;; 유효한 경우 각 객체의 값 설정(년도: 4자리, 월: 2자리) 
Usage : 
---------------------------------------------- */ 
function fn_isYearMonthByObj(objYear, objMonth) 

var isTrue = false; 

isTrue = fn_isYearMonthDay(objYear.value, objMonth.value, "01"); 

if ( isTrue && objYear.value != "" && objMonth.value != "") { 
objYear.value = fn_setFillzeroByVal(objYear.value, 4); 
objMonth.value = fn_setFillzeroByVal(objMonth.value, 2); 


return isTrue; 

//=============================================== 


/** ============================================= 
Return : boolean 
Comment: oYear, oMonth, oDay 값이 정상인경우 oDate 값을 세팅. (병합) 
Usage : 
---------------------------------------------- */ 
function fn_isDateObj_Mgr(objYear, objMonth, objDay, objDate) 

var isDate = false; 

if ( (objYear.value == "") && (objMonth.value == "") && (objDay.value == "") ) 
isDate = true; 

if ( fn_isYearMonthDay (objYear.value, objMonth.value, objDay.value) ) { 
objMonth.value = fn_setFillzeroByVal(objMonth.value, 2); 
objDay.value = fn_setFillzeroByVal(objDay.value, 2); 

isDate = true; 


if (isDate) 
objDate.value = objYear.value + objMonth.value + objDay.value; 

return isDate; 

//=============================================== 


/** ============================================= 
Return : boolean 
Comment: oDate 값이 정상인경우 oYear, oMonth, oDay 값을 세팅. (분리) 
Usage : 
---------------------------------------------- */ 
function fn_isDateObj_Sep(objYear, objMonth, objDay, objDate) 

var isDate = false; 

if (objDate.value.length == 8) { 
if ( fn_isYearMonthDay(objDate.value.substr(0,4), objDate.value.substr(4,2), objDate.value.substr(6,2)) ) { 
isDate = true; 
objYear.value = objDate.value.substr(0,4); 
objMonth.value = objDate.value.substr(4,2); 
objDay.value = objDate.value.substr(6,2); 

} else if (oDate.value == "") { 
isDate = true; 
objYear.value = ""; 
objMonth.value = ""; 
objDay.value = ""; 


return isDate; 

//=============================================== 


/** ============================================= 
Return : String (증가된 8자리 날자(YYYYMMDD)) 
Comment: yyyy, mm, dd 로 받은 날짜에서 val만큼 뺀 날짜를 리턴 
Usage : 
---------------------------------------------- */ 
function fn_date_add(yyyy, mm, dd, val) 

var iYear = yyyy; 
var iMonth = mm; 
var iDay = dd; 
var ival = val; 
ival = ival + dd; 

var iMaxDay = 0; 

while (true) { 
iMaxDay = fn_MaxdayYearMonth(iYear, iMonth); 
if (ival <= iMaxDay) { 
iDay = ival; 
break; 
} else { 
if (iMonth == 12) { 
iYear = iYear + 1; 
iMonth = 1; 
} else { 
iMonth = iMonth + 1; 

ival = ival - iMaxDay; 



return ( iYear.toString() + fn_setFillzeroByVal(iMonth.toString(), 2) + fn_setFillzeroByVal(iDay.toString(), 2) ); 

//=============================================== 


/** ============================================= 
Return : String (감소된 8자리 날자(YYYYMMDD)) 
Comment: yyyy, mm, dd 로 받은 날짜에서 val만큼 더한 날짜를 리턴 
Usage : 
---------------------------------------------- */ 
function fn_date_minus(yyyy, mm, dd, val) 

var iYear = yyyy; 
var iMonth = mm; 
var iDay = dd; 
var ival = val; 
var iMaxDay = 0; 

var isTrue = true; 
if (dd > ival) { 
iDay = dd - ival; 
isTrue = false; 
} else if (ival == dd) { 
ival = 0; 
} else 
ival = ival - dd; 

while (isTrue) { 
if (iMonth == 1) { 
iYear = iYear - 1; 
iMonth = 12; 
} else { 
iMonth = iMonth - 1; 


iMaxDay = fn_MaxdayYearMonth(iYear, iMonth); 

if (ival == 0) { 
ival = iMaxDay; 
iDay = ival; 
break; 
} else if (ival < iMaxDay) { 
iDay = iMaxDay - ival; 
break; 
} else { 
ival = ival - iMaxDay; 



return ( iYear.toString() + fn_setFillzeroByVal(iMonth.toString(), 2) + fn_setFillzeroByVal(iDay.toString(), 2) ); 

//=============================================== 

/** ============================================= 
Return : String 
Comment: sVal의 길이를 iLen으로 "0"으로 채워 맞춘 값을 리턴 
Usage : 
---------------------------------------------- */ 
function fn_setFillzeroByVal(sVal, iVal) 

sStr = sVal + ""; 

for (ii = sStr.length; ii < iVal; ii++) { 
sStr = "0" + sStr; 


return sStr; 

//===============================================


공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/01   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함