/* * Copyright (c) 2008 COOPS. All rights reserved. * * This software is the confidential and proprietary information of COOPS. * You shall not disclose such Confidential Information and shall use it * only in accordance with the terms of the license agreement you entered into * with COOPS. */ /** *
* 기능 : maxlength 의 길이에 따라 포커스 이동 * 날짜 : 2008. 06. 11 **@return this */ var inputArr = new Array(); function SFocus() { var tempArr = document.getElementsByTagName("input"); for ( i = 0; i < tempArr.length; i++ ) { if ( tempArr[i].maxLength != -1 && tempArr[i].maxLength != 2147483647 ) { inputArr.push(tempArr[i]); } } for ( j = 0; j < inputArr.length; j++ ) { inputArr[j].onkeyup = function() { focusMove(this); } } } function focusMove(obj) { if ( obj.value.length >= obj.maxLength ) { for ( k = 0; k < inputArr.length; k++ ) { if ( obj.name == inputArr[k].name ) { if ( inputArr[k+1] != null ) { inputArr[k+1].focus(); } } } } } /** *
* 기능 : 유효성을 체크 할 객체를 담는 객체 * 날짜 : 2008. 05. 14 **@return this */ function SForm() { /** * 멤버 변수 : 유효성을 체크 할 객체를 담는 객체 */ this.childrenArr = new Array; /** * 멤버 메소드 : 멤버 변수 childrenArr에 유효성을 체크 할 객체를 담아 주는 기능을 한다. */ this.add = sformAdd; /** * 멤버 메소드 : 유효성을 체크 할 객체의 validate 메소드를 실행시키는 기능을 한다. */ this.validate = sformValidate; return this; } /** *
* 기능 : 유효성을 체크 할 객체를 담는 객체 * 날짜 : 2008. 05. 14 ** * @param child * @return this */ function sformAdd(child) { this.childrenArr[this.childrenArr.length] = child; return this; } /** *
* 기능 : 유효성을 체크 할 객체의 validate 메소드를 실행시키는 기능을 담당한다. * 날짜 : 2008. 05. 14 ** * @return boolean */ function sformValidate() { for ( i = 0; i < this.childrenArr.length; i++) { if (!this.childrenArr[i].validate()) { return false; } } return true; } /** *
* 기능 : text 관련 유효성 체크 객체 * 날짜 : 2008. 05. 14 ** * @param name * object * @return this */ function SText(name, object) { /** * 멤버변수 : 유효성 체크 대상 이름 */ this.name = name; /** * 멤버변수 : 유효성 체크 대상 객체 */ this.object = object; /** * 멤버변수 : null 체크 여부 */ this.nullCheck = true; /** * 멤버변수 : text 객체의 길이 체크 여부 */ this.lengthCheck = false; /** * 멤버변수 : 특수 기호 체크 여부 */ this.specialCharCheck = false; /** * 멤버변수 : 한글만 입력받도록 하는 체크 여부 */ this.koreanCharCheck = false; /** * 멤버 변수 : 영문과 숫자만 입력받도록 하는 체크 여부 */ this.alphabetAndNumCheck = false; /** * 멤버변수 : 최소 길이 */ this.minLength; /** * 멤버변수 : 최대 길이 */ this.maxLength; /** * 멤버변수 : 객체의 타입 */ this.type = this.object.type; /** * 멤버메소드 : validation 체크 메소드 */ this.validate = s_validateText; /** * 멤버메소드 : null 체크 여부 변경 메소드 */ this.nullAble = s_nullAble; /** * 멤버메소드 : text 길이 체크 여부 변경 메소드 */ this.length = s_lengthCheck; /** * 멤버메소드 : 한글만 입력받도록 하는 체크 여부 변경 메소드 */ this.korean = s_koreanCharCheck; /** * 멤버메소드 : 영문과 숫자만 입력받도록 하는 체크 여부 변경 메소드 */ this.alphabetAndNum = s_alphabetAndNumCheck; /** * 멤버메소드 : text focus 메소드(text type) */ this.focus = s_focus; /** * 멤버메소드 : textarea focus 메소드(textarea type) */ this.textareaFocus = s_textareaFocus; /** * 멤버메소드 : 특수 문자 체크 여부 변경 메소드 */ this.specialChar = s_specialCharCheck; return this; } /** *
* 기능 : text 관련 유효성 체크 함수 * 날짜 : 2008. 05. 14 ** * @return boolean */ function s_validateText() { var value = this.object.value; if ( this.nullCheck && trim(value).length == 0 ) { alert(this.name + " 을(를 ) 입력해 주십시오."); if ( this.type == 'textarea' || this.type == 'hidden' ) { return this.textareaFocus(); } else { return this.focus(); } } if ( this.lengthCheck && trim(value).length != 0 && !checkTextLength(value, this.minLength, this.maxLength) ) { if ( this.minLength == this.maxLength ) { alert(this.name + " 의 길이는 " + this.minLength + " 이여야 합니다."); } else { alert(this.name + " 의 길이는" + this.minLength + " 과(와) " + this.maxLength +" 사이여야 합니다.") } if ( this.type == 'textarea' ) { return this.textareaFocus(); } else { return this.focus(); } } if ( this.specialCharCheck && trim(value).length != 0 && checkSpecialChar(value) ) { alert(this.name + " 에는 다음 특수문자(&-+=]}{[:;/><`~!,^%@?$()#*.'\|_)를 입력할 수 없습니다."); if ( this.type == 'textarea' ) { return this.textareaFocus(); } else { return this.focus(); } } if ( this.type == 'textarea' ) { var length = parseInt(15*100*100); if(!checkTextLength(value, 0, parseInt(length*2))) { alert(this.name + " 의 길이는 " + length + " 자 이내여야 합니다."); return this.textareaFocus(); } } if ( this.koreanCharCheck && !checkKoreanChar(value)) { alert(this.name + " 은(는) 한글만 입력 할 수 있습니다."); return this.focus(); } if ( this.alphabetAndNumCheck && ! checkAlphabetAndNum(value)) { alert(this.name + " 은(는) 영문과 숫자만 입력 할 수 있습니다."); return this.focus(); } return true; } /** *
* 기능 : 인자값으로 받은 value의 길이가 최소값 min과 최대값max * 사이에 있는지 여부에 따라 boolean값을 리턴한다. * 날짜 : 2008. 05. 14 ** * @param value * min * max * @return boolean */ function checkTextLength(value, min, max) { var total = 0; for (i = 0; i < value.length; i++) { var a = value.charAt(i); /* 한글인 경우 길이가 6 */ if (escape(a).length >= 6) { total = total + 2; } else { total = total + 1; } } return total >= min && total <= max; } /** *
* 기능 : 인자값으로 받은 value 객체 안에 특수 문자가 존재하는지 여부에 따라 * boolean 값을 리턴한다. * 날짜 : 2008. 05. 14 ** * @param value * @return boolean */ function checkSpecialChar(value) { var specialChars = "&-+=]}{[:;/><`~!,^%@?$()#*.'\|_"; for (i = 0; i < value.length; i++) { /* Check that current character letter. */ var char = value.charAt(i); if (specialChars.indexOf(char) >= 0) { return true; } } return false } /** *
* 기능 : 인자값으로 받은 value 객체 안에 한글만이 존재하는지 검사하여 boolean 값을 리턴한다. * 날짜 : 2008. 05. 14 ** * @param value * @return boolean */ function checkKoreanChar(value) { for ( i = 0; i < value.length; i++ ) { if (value.charCodeAt(i) < 128 ) { return false; } } return true; } /** *
* 기능 : 인자값으로 받은 value 객체 안에 영문과 숫자만이 존재하는지 * 검사하여 boolean 값을 리턴한다. * 날짜 : 2008. 05. 14 ** * @param value * @return boolean */ function checkAlphabetAndNum(value) { for ( i = 0; i < value.length; i++ ) { if (48 > value.charCodeAt(i) || (value.charCodeAt(i) > 57 && value.charCodeAt(i) < 65 ) || (value.charCodeAt(i) > 90 && value.charCodeAt(i) < 97 ) || value.charCodeAt(i) > 122 ) { return false; } } return true; } /** *
* 기능 : 숫자 관련 유효성 체크 객체 * 날짜 : 2008. 05. 14 ** * @param name * object * @return this */ function SNumber(name, object) { /** * 멤버변수 : 유효성 체크 대상 이름 */ this.name = name; /** * 멤버변수 : 유효성 체크 대상 객체 */ this.object = object; /** * 멤버변수 : null 체크 여부 */ this.nullCheck = true; /** * 멤버변수 : 숫자 객체의 자릿수 체크 여부 */ this.lengthCheck = false; /** * 멤버변수 : 숫자 객체의 크기 체크 여부 */ this.sizeCheck = false; /** * 멤버변수 : 최소크기 */ this.minSize; /** * 멤버변수 : 최대크기 */ this.maxSize; /** * 멤버변수 : 최소 자릿수 */ this.minLength; /** * 멤버변수 : 최대 자릿수 */ this.maxLength; /** * 멤버 메소드 : 숫자 관련 validation 체크 메소드 */ this.validate = s_validateNum; /** * 멤버 메소드 : null 체크 여부 변경 메소드 */ this.nullAble = s_nullAble; /** * 멤버 메소드 : 숫자 객체 길이 체크 여부 변경 메소드 */ this.length = s_lengthCheck; /** * 멤버 메소드 : 숫자 객체 크기 체크 여부 변경 메소드 */ this.size = s_sizeCheck; /** * 멤버메소드 : text focus 메소드(text type) */ this.focus = s_focus; return this; } /** *
* 기능 : 숫자 관련 유효성 체크 메소드 * 날짜 : 2008. 05. 14 ** * @return boolean */ function s_validateNum() { var numValue = this.object.value; if ( this.nullCheck && trim(numValue).length == 0 ) { alert(this.name + " 을(를 ) 입력하여 주십시오."); return this.focus(); } if ( isNaN(numValue) ) { alert(this.name + " 는 숫자만 입력 가능합니다."); return this.focus(); } if ( this.sizeCheck && trim(numValue).length !=0 && !checkNumSize(numValue, this.minSize, this.maxSize)) { if (this.minSize == this.maxSize) { alert("입력 할 수 있는 " + this.name + " 의 숫자는 " + this.minSize + " 이여야 합니다."); } else { alert("입력 할 수 있는 " + this.name + "의 숫자는 " + this.minSize + " 와(과) " + this.maxSize + " 사이이여야 합니다."); } return this.focus(); } if ( this.lengthCheck && !checkNumLength(numValue, this.minLength, this.maxLength)) { if ( this.minLength == this.maxLength ) { alert("입력 할 수 있는 " + this.name + " 의 숫자의 자릿수는 " + this.minLength + " 자릿수 여야 합니다."); } else { alert("입력 할 수 있는 " + this.name + " 의 숫자의 자릿수는 " + this.minLength + " 와(과) " + this.maxLength + " 사이여야 합니다."); } return this.focus(); } return true; } /** *
* 기능 : select 관련 유효성 체크 객체 * 날짜 : 2008. 05. 14 ** * @param name * object * @return this */ function SSelect(name, object) { /** * 멤버변수 : 유효성 체크 대상 이름 */ this.name = name; /** * 멤버변수 : 유효성 체크 대상 객체 */ this.object = object; /** * 멤버변수 : 최소 갯수 */ this.minSize; /** * 멤버변수 : 최대 갯수 */ this.maxSize; /** * 멤버변수 : null 체크 여부 */ this.nullCheck = true; /** * 멤버변수 : select 갯수 체크 여부 */ this.sizeCheck = false; /** * 멤버 메소드 : select 관련 validation 체크 메소드 */ this.validate = s_validateSelect; /** * 멤버 메소드 : null 체크 여부 변경 메소드 */ this.nullAble = s_nullAble; /** * 멤버 메소드 : select 갯수 체크 여부 변경 메소드 */ this.size = s_sizeCheck; /** * 멤버 메소드 : select focus 메소드 */ this.focus = s_selectFocus; return this; } /** *
* 기능 : select 박스 관련 유효성 체크 메소드 * 날짜 : 2008. 05. 14 ** * @return boolean */ function s_validateSelect() { var value = this.object.value; if (this.nullCheck && trim(value).length == 0) { alert(this.name + " 을(를) 선택하여 주십시오."); return this.focus(); } var number = selectedNum(this.object); if (this.sizeCheck && number != 0 && (number < this.minSize || number > this.maxSize)) { if (this.minSize == this.maxSize) { alert("선택할 수 있는 " + this.name + " 의 수는 " + this.minSize + " 입니다."); } else { alert(this.name + " 은(는) 최소 " + this.minSize + " 개 , 최대 " + this.maxSize + " 개까지 선택 할 수 있습니다."); } return this.focus(); } return true; } /** *
* 기능 : 인자값으로 받은 ojb 객체의 selected 된 수를 구하여 그 값을 리턴한다. * 날짜 : 2008. 05. 14 ** * @param obj * @return number */ function selectedNum(obj) { if ( obj == null) { return 0; } var number = 0; for (var i = 0; i < obj.length; i++) { if (obj[i].selected) { number++; } } return number; } /** *
* 기능 : check 박스 관련 유효성 체크 메소드 * 날짜 : 2008. 05. 14 ** @param name * object * @return this */ function SCheck(name, object) { /** * 멤버변수 : 유효성 체크 대상 이름 */ this.name = name; /** * 멤버변수 : 유효성 체크 대상 객체 */ this.object = object; /** * 멤버변수 : 최소 checked 갯수 */ this.minSize; /** * 멤버변수 : 최대 checked 갯수 */ this.maxSize; /** * 멤버변수 : null 체크 여부 */ this.nullCheck = true; /** * 멤버변수 : checked 갯수 체크 여부 */ this.sizeCheck = false; /** * 멤버 메소드 : check 박스 validation 체크 메소드 */ this.validate = s_validateCheck; /** * 멤버메소드 : null 체크 여부 변경 메소드 */ this.nullAble = s_nullAble; /** * 멤버메소드 : checked 갯수 체크 여부 변경 메소드 */ this.size = s_sizeCheck; /** * 멤버메소드 : check 박스 focus 메소드 */ this.focus = s_checkFocus; return this; } /** *
* 기능 : check 박스 관련 유효성 체크 메소드 * 날짜 : 2008. 05. 14 ** * @return boolean */ function s_validateCheck() { var number = checkedNum(this.object); if (this.nullCheck && number == 0) { alert(this.name + " 을(를) 선택하여 주십시오."); return this.focus(); } if (this.sizeCheck && number != 0 && (number < this.minSize || number > this.maxSize)) { if (this.minSize == this.maxSize) { alert("선택할 수 있는 " + this.name + " 의 수는 " + this.minSize + " 입니다."); } else { alert(this.name + " 은(는) 최소 " + this.minSize + " 개 , 최대 " + this.maxSize + " 개까지 선택 할 수 있습니다."); } return this.focus(); } return true; } /** *
* 기능 : 인자값으로 받은 ojb 객체의 checked 된 수를 구하여 그 값을 리턴한다. * 날짜 : 2008. 05. 14 ** * @param obj * @return number */ function checkedNum(obj) { if ( obj == null) { return 0; } var number = 0; if ( obj.checked) { return 1; } for (var i = 0; i < obj.length; i++) { if (obj[i].checked) { number++; } } return number; } /** *
* 기능 : 인자값으로 받은 value 값의 크기가 인자값으로 받은 * 최소값 min 과 최대값 max값 사이에 있는지에 따라 boolean 값을 리턴한다. * 날짜 : 2008. 05. 14 ** * @param value * min * max * @return boolean */ function checkNumSize(value, min, max) { if ( min <= value && value <= max) { return true; } else { return false; } } /** *
* 기능 : 인자값으로 받은 value 값의 길이가 인자값으로 받은 * 최소값 min 과 최대값 max값 사이에 있는지에 따라 boolean 값을 리턴한다. * 날짜 : 2008. 05. 14 ** * @param value * min * max * @return boolean */ function checkNumLength(value, min, max) { if ( min <= value.length && value.length <= max) { return true; } else { return false; } } /** *
* 기능 : null 체크 여부를 false로 변경한다. * 날짜 : 2008. 05. 14 **@return this */ function s_nullAble() { this.nullCheck = false; return this; } /** *
* 기능 : 특수 문자 체크 여부를 true값으로 변경한다. * 날짜 : 2008. 05. 14 **@return this */ function s_specialCharCheck() { this.specialCharCheck = true; return this; } /** *
* 기능 : 한글 문자 체크 여부를 true값으로 변경한다. * 날짜 : 2008. 05. 14 **@return this */ function s_koreanCharCheck() { this.koreanCharCheck = true; return this; } /** *
* 기능 : 영문과 숫자 체크 여부를 true값으로 변경한다. * 날짜 : 2008. 05. 14 **@return this */ function s_alphabetAndNumCheck() { this.alphabetAndNumCheck = true; return this; } /** *
* 기능 : size 체크 여부를 true값으로 변경하고 멤버변수 minSize와 maxSize를 stting 한다. * 날짜 : 2008. 05. 14 **@param min * max *@return this */ function s_sizeCheck(min, max) { this.sizeCheck = true; this.minSize = min; this.maxSize = max; return this; } /** *
* 기능 : length 체크 여부를 true값으로 변경한고 멤버 변수 minSize와 maxSize를 setting 한다. * 날짜 : 2008. 05. 14 **@param min * max *@return this */ function s_lengthCheck(min, max){ this.lengthCheck = true; this.minLength = min; this.maxLength = max; return this; } /** *
* 기능 : object 객체에 focus와 select를 주고 false값을 리턴한다. * 날짜 : 2008. 05. 14 **@return false */ function s_focus() { this.object.focus(); this.object.select(); return false; } /** *
* 기능 : object 객체에 focus를 주고 object 객체 값에 object 값을 setting함으로서 textarea 글 마지막 부분에 focus를 준다. false 값을 리턴한다. * 날짜 : 2008. 05. 14 **@return false */ function s_textareaFocus() { this.object.focus(); this.object.value = this.object.value; return false; } /** *
* 기능 : object 객체에 focus를 주고 false값을 리턴한다. * 날짜 : 2008. 05. 14 **@return false */ function s_selectFocus() { this.object.focus(); return false; } /** *
* 기능 : false 값을 리턴한다. * 날짜 : 2008. 05. 14 **@return false */ function s_checkFocus() { return false; } /** *
* 기능 : 인자값으로 받은 value의 공백을 제거한다. * 날짜 : 2008. 05. 14 **@param value *@return value */ function trim(value) { value = value.replace(/^\s+/, ""); value = value.replace(/\s+$/g, ""); return value; } /** *
* 기능 : 주민등록번호 관련 유효성 체크 객체 * 날짜 : 2008. 05. 14 ** @param name * object * @return this */ function SSsn(name, object) { /** * 멤버변수 : 유효성 체크 대상 이름 */ this.name = name; /** * 멤버변수 : 유효성 체크 대상 객체 */ this.object = object; /** * 멤버변수 : null 체크 여부 */ this.nullCheck = true; /** * 멤버 메소드 : 유효성 체크 메소드 */ this.validate = s_validateSsn; /** * 멤버 메소드 : null 체크 여부 변경 메소드 */ this.nullAble = s_nullAble; /** * 멤버메소드 : focus 메소드 */ this.focus = s_focus; return this; } /** *
* 기능 : 주민등록번호 관련 유효성 체크 메소드 * 날짜 : 2008. 05. 14 ** * @return boolean */ function s_validateSsn() { var value = this.object.value; if (this.nullCheck && trim(value).length == 0) { alert(this.name + " 을(를) 입력하여 주십시오."); return this.focus(); } if (isNaN(value.replace(/-|\s+/g, ""))) { alert(this.name + " 에는 숫자만 입력하여 주십시오."); return this.focus(); } var year = value.substring(0, 2); var month = value.substring(2, 4); var day = value.substring(4, 6); var sex = value.substring(6, 7); if ((value.length != 13 ) || (year < 25 || month < 1 || month >12 || day < 1 || day > 31)) { alert(this.name + " 을(를) 올바르게 입력하여 주십시오."); return this.focus(); } if ((sex != 1 && sex !=2 && sex !=3 && sex !=4)) { alert(this.name + " 을(를) 올바르게 입력하여 주십시오."); return this.focus(); } return true; } /** *
* 기능 : 이메일 주소 관련 유효성 체크 객체 * 날짜 : 2008. 05. 15 ** @param name * object * @return this */ function SEmail(name, object) { /** * 멤버변수 : 유효성 체크 대상 이름 */ this.name = name; /** * 멤버변수 : 유효성 체크 대상 객체 */ this.object = object; /** * 멤버변수 : null 체크 여부 */ this.nullCheck = true; /** * 멤버 메소드 : null 체크 여부 변경 메소드 */ this.nullAble = s_nullAble; /** * 멤버 메소드 : Email 주소 관련 유효성 체크 메소드 */ this.validate = s_validateEmail; /** * 멤버메소드 : focus 메소드 */ this.focus = s_focus; return this; } /** *
* 기능 : 이메일 주소 관련 유효성 체크 메소드 * 날짜 : 2008. 05. 15 ** @return boolean */ function s_validateEmail() { var value = this.object.value; if ( this.nullCheck && trim(value).length == 0 ) { alert(this.name + " 을(를) 입력해 주십시오"); return this.focus(); } var regExp = new RegExp('[-a-z0-9_]\@[-a-z0-9_]{2,}\.[-a-z0-9_]{2,}','i'); if ( !regExp.test(value) ) { alert(this.name + " 은(는) 올바른 형식이 아닙니다."); return this.focus(); } return true; } /** *
* 기능 : 전화번호 관련 유효성 체크 객체 * 날짜 : 2008. 05. 15 ** @param name * object * @return this */ function SPhone(name, object) { /** * 멤버변수 : 유효성 체크 대상 이름 */ this.name = name; /** * 멤버변수 : 유효성 체크 대상 객체 */ this.object = object; /** * 멤버변수 : null 체크 여부 */ this.nullCheck = true; /** * 멤버변수 : length 체크 여부 */ this.lengthCheck = false; /** * 멤버변수 : min Length */ this.minLength; /** * 멤버변수 : max Length */ this.maxLength; /** * 멤버 메소드 : null 체크 여부 변경 메소드 */ this.nullAble = s_nullAble; /** * 멤버 메소드 : length 체크 여부 변경 메소드 */ this.length = s_lengthCheck; /** * 멤버 메소드 : 전화번호 관련 유효성 체크 메소드 */ this.validate = s_validatePhone; /** * 멤버메소드 : focus 메소드 */ this.focus = s_focus; return this; } /** *
* 기능 : 전화번호 주소 관련 유효성 체크 메소드 * 날짜 : 2008. 05. 15 ** @return boolean */ function s_validatePhone() { var value = this.object.value; if ( this.nullCheck && trim(value).length == 0 ) { alert(this.name + " 을(를) 입력해 주십시오"); return this.focus(); } if ( isNaN(value) ) { alert(this.name + " 에는 숫자만 입력하여 주십시오."); return this.focus(); } if ( this.lengthCheck && !checkNumLength(value,this.minLength,this.maxLength) ) { alert(this.name + " 은(는) 최소 " + this.minLength + " 자리, 최대 " + this.maxLength + " 자리까지 가능합니다."); return this.focus(); } return true; } /** *
* 기능 : 파일 업로드 관련 유효성 체크 객체 * 날짜 : 2008. 05. 15 ** @param object * name * @return this */ function SFile(name, object) { /** * 멤버변수 : 유효성 체크 대상 이름 */ this.name = name; /** * 멤버변수 : 유효성 체크 대상 객체 */ this.object = object; /** * 멤버변수 : null 체크 여부 */ this.nullCheck = true; /** * 멤버변수 : 허가된 확장자를 가지고 있는 배열 */ this.includeExtensionArr; /** * 멤버변수 : 차단된 확장자를 가지고 있는 배열 */ this.excludeExtensionArr; /** * 멤버 메소드 : null 체크 여부 변경 메소드 */ this.nullAble = s_nullAble; /** * 멤버 메소드 : 파일업로드 관련 유효성 체크 메소드 */ this.validate = s_validateFile; /** * 멤버 메소드 : 허가된 확장자 체크 여부 변경 메소드 */ this.includeExtension = s_includeExtension; /** * 멤버 메소드 : 차단된 확장자 체크 여부 변경 메소드 */ this.excludeExtension = s_excludeExtension; return this; } /** *
* 기능 : 파일 업로드 관련 유효성 체크 메소드 * 날짜 : 2008. 05. 15 ** @return boolean */ function s_validateFile() { if ( this.object.length ) { var index = 0; var tempObj = new Array(); for ( i = 0; i < this.object.length; i++ ) { if ( trim(this.object[i].value).length != 0 ) { tempObj[index] = trim(this.object[i].value); index = index + 1; } } this.object = tempObj; } else { var tempValue = this.object.value; this.object = new Array(); this.object[0] = tempValue; } /* * null 체크 */ if( this.nullCheck ) { var existNum = 0; for ( i = 0; i < this.object.length; i++ ) { if ( this.object[i].length != 0 ) { existNum = existNum + 1; } } if ( existNum == 0 ) { alert(this.name + " 에 파일를 첨부해 주십시오"); return false; } } for ( i = 0; i < this.object.length; i++ ) { if ( this.object[i].split(".").length != 2 ) { alert ( this.name + " 는 올바른 형식의 파일이 아닙니다."); return false; } } if ( this.includeExtensionArr && !includeExtensionCheck(this.object, this.includeExtensionArr) ) { alert ( this.name + " 에 첨부 가능한 파일의 확장자는 " + this.includeExtensionArr.join(", ") + " 입니다."); return false; } if ( this.excludeExtensionArr && !excludeExtensionCheck(this.object, this.excludeExtensionArr) ) { alert ( this.name + " 에 " + this.excludeExtensionArr.join(", ") + " 확장자는 첨부 가능하지 않습니다."); return false; } return true; } /** *
* 기능 : 허가된 확장자를 가지고 있는 여부에 따라 boolean 값을 리턴한다. * 날짜 : 2008. 05. 15 ** @param object * includeExtensionArr * @return boolean */ function includeExtensionCheck(object,includeExtensionArr) { var extension; var extensionCheckNum = 0; for ( i = 0; i < object.length; i++ ) { extension = object[i].split(".")[1]; for ( j = 0; j < includeExtensionArr.length; j++ ) { if ( includeExtensionArr[j] == extension ) { extensionCheckNum = extensionCheckNum + 1; break; } } if ( extensionCheckNum == 0 ) { return false; } else { extensionCheckNum = 0; } } return true; } /** *
* 기능 : 차단된 확장자를 가지고 있는 여부에 따라 boolean 값을 리턴한다. * 날짜 : 2008. 05. 15 ** @param object * excludeExtensionArr * @return boolean */ function excludeExtensionCheck(object,excludeExtensionArr) { var extension; for ( i = 0; i < object.length; i++ ) { extension = object[i].split(".")[1]; for ( j = 0; j < excludeExtensionArr.length; j++ ) { if ( excludeExtensionArr[j] == extension ) { return false; } } } return true; } /** *
* 기능 : 허가된 확장자를 가지고 있는 배열 setting * 날짜 : 2008. 05. 15 ** @param array * @return this */ function s_includeExtension(array) { this.includeExtensionArr = array; return this; } /** *
* 기능 : 차단된 확장자를 가지고 있는 배열 setting * 날짜 : 2008. 05. 15 ** @param array * @return this */ function s_excludeExtension(array) { this.excludeExtensionArr = array; return this; } /******************************************************************************************** **************************** className 을 이용한 validation Check ***************************** ********************************************************************************************* ************************************ 클래스 네임 설정 방법 *************************************** ************************ x_xxxx_xxxxxx 의 형식으로 클래스 네임을 설정한다. ************************** ************************ 처음 자릿수에는 t or f를 넣는다. ***************************************** ************************ t: 널체크를 한다. f : 널체크를 하지 않는다. ****************************** ***************** 다음 자리에는 text,num, select, check, phone, email, ssn 이 올 수 있다 *********** ***************** text : 텍스트 유효성 체그 ****************************************************** ***************** num : 숫자 유효성 체그 ********************************************************* ***************** select : select 유효성 체그 *************************************************** ***************** check : check box 유효성 체그 ************************************************* ***************** phone : phone 유효성 체그 ***************************************************** ***************** email : email 유효성 체그 ***************************************************** ***************** ssn : ssn 유효성 체그 ********************************************************* ***************** 그 다음 자리에는 각 유효성 체크 객체의 option 이 올 수 있다. **************************** ***************** 각 유효성 체크 객체별 옵션 ******************************************************** ***************** text************************************************************************ ********************* lengthxtox : text 길이 유효성 체크(최소길이와 최대길이를 to로 구분한다) ********** ************************ ex) t_text_length4to9 (최소길이 4 최대길이 9로 제한한다) ****************** ********************* korean : 한글만 입력 가능 ************************************************* ************************ ex) t_text_korean ************************************************** ********************* alphabetAndNum : 알파벳과 숫자만 입력가능 *********************************** ************************ ex) t_text_alphabetAndNum ****************************************** ********************* specialChar : 특수 문자 입력 제한 ****************************************** ************************ ex) t_text_specialChar ********************************************* ***************** 모든 옵션은 중복 가능한다. ****************************************************** ***************** num : 숫자 유효성 체그 ********************************************************* ********************* lengthxtox : number 길이 유효성 체크(최소길이와 최대길이를 to로 구분한다) ********* ************************ ex) t_num_length4to9 (최소길이 4 최대길이 9로 제한한다) ****************** ********************* sizextox : number 크기 유효성 체크(최소값과 최대값를 to로 구분한다) ************** ************************ ex) t_num_size4to9 (최소값4 최대값 9로 제한한다) ************************ ***************** 모든 옵션은 중복 가능한다. ****************************************************** ***************** select : select 유효성 체그 *************************************************** ********************* sizextox : select 선택갯수 유효성 체크(최소갯수와 최대갯수를 to로 구분한다) ******* ************************ ex) t_select_size4to9 (최소갯수4 최대갯수 9로 제한한다) ******************* ***************** check : check box 유효성 체그 ************************************************* ********************* sizextox : checkbox 선택갯수 유효성 체크(최소갯수와 최대갯수를 to로 구분한다) ******* ************************ ex) t_checkbox_size4to9 (최소갯수4 최대갯수 9로 제한한다) ***************** ***************** phone : phone 유효성 체그 ***************************************************** ********************* lengthxtox : phone 길이 유효성 체크(최소길이와 최대길이를 to로 구분한다) ********** ************************ ex) t_phone_size4to9 (최소길이4 최대길이 9로 제한한다) ******************* ***************** email : email 유효성 체그 ***************************************************** ********************* 옵션 없음 ***************************************************************** ***************** ssn : ssn 유효성 체그 ********************************************************* ********************* 옵션 없음 ***************************************************************** */ /** *
* 기능 : 클래스 네임을 이용한 유효성 체크 객체 * 날짜 : 2008. 05. 15 ** @param form * @return this */ function SValidationWithCName(form) { /* * 멤버변수 : 유효성 체크 대상 form */ this.targetForm = new Array(); /* * 멤버변수 : temp form */ this.tempForm = form; /* * 멤버 메소드 : 클래스 네임을 이용한 유효성 체크 메소드 */ this.validate = s_validationWithCName; return this; } /** *
* 기능 : 클래스 네임을 이용한 유효성 체크 객체 * 날짜 : 2008. 05. 15 ** @return boolean */ function s_validationWithCName() { var index = 0; for ( i = 0; i < this.tempForm.childNodes.length; i++ ) { if ( this.tempForm.childNodes[i].className != null && this.tempForm.childNodes[i].className != "" ) { this.targetForm[index] = this.tempForm.childNodes[i]; index = index + 1; } } var checkArr = new Array(); var checkIdx = 0; var checkStr = ""; var checkNullStr = ""; var checkName = ""; for ( j = 0; j < this.targetForm.length; j++ ) { var arr = (this.targetForm[j].className).split('_'); var execStr = ""; if ( arr[0] == 'f' ) { execStr = ".nullAble()" } if ( arr[1] == 'text' ) { execStr = "new SText(this.targetForm[j].name, this.targetForm[j])" + execStr; for ( k = 2; k < arr.length; k++ ) { if ( arr[k].substring(0,6) == 'length' ) { execStr = execStr + "." + arr[k].substring(0,6) + "(" + arr[k].substring(6,arr[k].length).split('to').join(', ')+ ")"; } if ( arr[k] == 'korean' ) { execStr = execStr + "." + arr[k] + "()"; } if ( arr[k] == 'alphabetAndNum' ) { execStr = execStr + "." + arr[k] + "()"; } if ( arr[k] == 'specialChar' ) { execStr = execStr + "." + arr[k] + "()"; } } execStr = execStr + ".validate()"; if ( !eval(execStr) ) { return false; } } if ( arr[1] == 'num' ) { execStr = "new SNumber(this.targetForm[j].name, this.targetForm[j])" + execStr; for ( k = 2; k < arr.length; k++ ) { if ( arr[k].substring(0,6) == 'length' ) { execStr = execStr + "." + arr[k].substring(0,6) + "(" + arr[k].substring(6,arr[k].length).split('to').join(', ')+ ")"; } if ( arr[k].substring(0,4) == 'size' ) { execStr = execStr + "." + arr[k].substring(0,4) + "(" + arr[k].substring(4,arr[k].length).split('to').join(', ')+ ")"; } } execStr = execStr + ".validate()"; if ( !eval(execStr) ) { return false; } } if ( arr[1] == 'select' ) { execStr = "new SSelect(this.targetForm[j].name, this.targetForm[j])" + execStr; for ( k = 2; k < arr.length; k++ ) { if ( arr[k].substring(0,4) == 'size' ) { execStr = execStr + "." + arr[k].substring(0,4) + "(" + arr[k].substring(4,arr[k].length).split('to').join(', ')+ ")"; } } execStr = execStr + ".validate()"; if ( !eval(execStr) ) { return false; } } if ( arr[1] == 'check' ) { checkArr[checkIdx] = this.targetForm[j]; checkIdx = checkIdx + 1; checkName = this.targetForm[j].name for ( k = 2; k < arr.length; k++ ) { if ( arr[k].substring(0,4) == 'size' ) { checkStr = "." + arr[k].substring(0,4) + "(" + arr[k].substring(4,arr[k].length).split('to').join(', ')+ ")"; } } if ( arr[0] == 'f' ) { checkNullStr = ".nullAble()"; } } if ( arr[1] == 'ssn' ) { execStr = "new SSsn(this.targetForm[j].name, this.targetForm[j])" + execStr; execStr = execStr + ".validate()"; if ( !eval(execStr) ) { return false; } } if ( arr[1] == 'phone' ) { execStr = "new SPhone(this.targetForm[j].name, this.targetForm[j])" + execStr; for ( k = 2; k < arr.length; k++ ) { if ( arr[k].substring(0,6) == 'length' ) { execStr = execStr + "." + arr[k].substring(0,6) + "(" + arr[k].substring(6,arr[k].length).split('to').join(', ')+ ")"; } } execStr = execStr + ".validate()"; if ( !eval(execStr) ) { return false; } } if ( arr[1] == 'email' ) { execStr = "new SEmail(this.targetForm[j].name, this.targetForm[j])" + execStr; execStr = execStr + ".validate()"; if ( !eval(execStr) ) { return false; } } } if ( checkArr.length > 0 ) { execStr = "new SCheck(checkName, checkArr)" + checkNullStr + checkStr; execStr = execStr + ".validate()"; if ( !eval(execStr) ) { return false; } } return true; }