-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /var/www/html/inc/js/
File Upload :
Current File : /var/www/html/inc/js/common.form.js

function _chkForm(f) {
	var emsg , dreq , target ;
	var minn = 0 , maxn ;  
	for (var i=0; i < f.length; i++) {
		x = f[i];
		if (x.disabled) continue;
		emsg = typeof x.getAttribute('emsg') == 'string' ? x.getAttribute('emsg') : ' ÀԷ»çÇ×À» ´Ù½Ã È®ÀÎÇØÁÖ¼¼¿ä '  ;
		dreq = typeof x.getAttribute('dreq') == 'string' ? true : false ; // new attribute name
		dreq = typeof x.getAttribute('required') == 'string' ? true : dreq ;  // old attribute name
		switch ( x.type ) {
			case 'radio' : if ( dreq ) { if (!chkGRP(x)) return errormsg(null, emsg, false); } break;
			case 'checkbox' : if (dreq) { if (!chkGRP(x)) return errormsg(null, emsg, false); } break;
			case 'select-one' :
			case 'select' : if (dreq) { if (x.value == '') return errormsg(null, emsg, false); } break;
			case 'text' :
			case 'password' :
				target = x.readOnly || x.style.display == 'none' || x.style.visibility == 'hidden' ? null : x ;  // possible focus
				if ( dreq ) { // required check 
					minn = typeof x.getAttribute('minnum') == 'string' ? x.getAttribute('minnum') : 1 ; 
					if ( typeof x.getAttribute('maxnum') == 'string'  ) { // string limit
						if (!chknull(x.value,minn)) return errormsg(target, emsg, false); 
					} else {
						if (!chknull(x.value,minn,x.getAttribute('maxnum'))) return errormsg(target, emsg, false);
					}
				}
				if (chknull(x.value,minn)) {
					switch ( x.getAttribute('vtype') ) {
						case 'id' : if (!chkID(x.value)) return errormsg(target, emsg, false); break;
						case 'number' : if (!chknum(x.value)) return errormsg(target, emsg, false); if ( typeof x.getAttribute('cutline') == 'string' ) { if ( parseInt(x.value,10) < parseInt(x.getAttribute('cutline'),10) ) return errormsg(target, x.getAttribute('cutline') + ' ÀÌ»ó ÀÔ·ÂÇØÁÖ¼¼¿ä ', false); } if ( typeof x.getAttribute('deadline') == 'string' ) { if ( parseInt(x.value,10) > parseInt(x.getAttribute('deadline'),10) ) return errormsg(target, x.getAttribute('deadline') + 'ÀÌÇÏ·Î ÀÔ·ÂÇØÁÖ¼¼¿ä', false); } break;
						case 'email' : if (!chkMAIL(x.value)) return errormsg(target, emsg, false); break;
						case 'email2step' : if (!chkMAIL(x.value + '@' + f.elements[x.getAttribute('tname')].value)) return errormsg(target, emsg, false); break;
						case 'phone' : if (typeof x.getAttribute('group') == 'string') { if (!chkPHONE(f.elements[x.getAttribute('group') + '1'].value + '-' + f.elements[x.getAttribute('group') + '2'].value + '-' + f.elements[x.getAttribute('group') + '3'].value)) return errormsg(null, emsg, false); } else { if (!chkPHONE(x.value)) return errormsg(target, emsg, false); } break;
						case 'rrn' : if (typeof x.getAttribute('group') == 'string') { if (!chkRRN(f.elements[x.getAttribute('group') + '1'].value, f.elements[x.getAttribute('group') + '2'].value)) return errormsg(null, emsg, false); } else { if (!chkRRN(x.value)) return errormsg(target, emsg, false); } break;
						case 'company' : if (typeof x.getAttribute('group') == 'string') { if (!chkCMP(f.elements[x.getAttribute('group') + '1'].value + '' + f.elements[x.getAttribute('group') + '2'].value + '' + f.elements[x.getAttribute('group') + '3'].value)) return errormsg(null, emsg, false); } else { if (!chkCMP(x.value)) return errormsg(target, emsg, false); } break;
						case 'english' : if (!chkkr(x.value)) return errormsg(target, emsg, false); break;
						case 'file' : if (typeof x.getAttribute('useext') == 'string' && x.getAttribute('useext') != 'all') { tmp_useext = x.getAttribute('useext'); tmp_useext = tmp_useext.split(','); tmp_fileext = x.value.substring(x.value.lastIndexOf('.')+1); tmp_fileokay = true; for (var j=0; j < tmp_useext.length; j++) { if (tmp_fileext.toLowerCase().match(tmp_useext[j].toLowerCase())) { tmp_fileokay = false; break; } } if (tmp_fileokay) { x.value = ''; return errormsg(x, emsg, false); break; } } break;
						case 'same' : if (typeof x.getAttribute('tname') == 'string' ) { if ( x.value != f.elements[x.getAttribute('tname')].value ) { return errormsg(target , ' °ªÀÌ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù. ', false) ;} } break ;
					}
				}
				break;
			case 'hidden' : if (dreq) { if (!chknull(x.value,1)) return errormsg(null, emsg, false); } break;
			case 'file' :
				//f.encType = "multipart/form-data";
				if (dreq) { if (!chknull(x.value,1)) return errormsg(x, emsg, false); }
				if (chknull(x.value,1)) {
					if (typeof x.getAttribute('useext') == 'string' && x.getAttribute('useext') != 'all') {
						tmp_useext = x.getAttribute('useext') ;
						tmp_useext = tmp_useext.split(',');
						tmp_fileext = x.value.substring(x.value.lastIndexOf('.')+1);
						tmp_fileokay = true;
						for (var j=0; j < tmp_useext.length; j++) { if (tmp_fileext.toLowerCase().match(tmp_useext[j].toLowerCase())) { tmp_fileokay = false; break; } }
						if (tmp_fileokay) { x.select(); document.execCommand('Delete'); return errormsg(x, emsg, false); break; }
					}
				}
				break;
			case 'textarea' :
				if (dreq) { if (!chknull(x.value,1)) return errormsg(x, emsg, false); }
				if (typeof x.getAttribute('htmlmode') == 'string') {
					if (x.style.display == 'none') {
						Toggle('changeMode',' ', x.name);
					}
				}
				break;
		}
	}
	return true;
}

function _nextFocus( thisObj , nextObjName ) {
	if ( typeof thisObj == 'object' ) {
		if ( thisObj.value.length == thisObj.maxLength ) {
			nextObj = thisObj.form.elements[nextObjName] ;
			if ( typeof nextObj == 'object' ) nextObj.focus();
		}
	}
}

function _inputValues( target1 , target2 , target2_value ) {
	target1_idx = 0 ;
	for ( i = 0; i < target1.form.elements[target1.name].length; i++) {
		if ( target1.form.elements[target1.name][i] == target1 ) {
			target1_idx = i ; break ;
		}
	}

	target2[target1_idx].value = target2_value ;
}

Copyright © 2017 || Recoded By Mr.Bumblebee