mc_chkFormular.inc.js 5.36 KB
var var_preInputName;
var var_toCheck = new Array();
var var_valueCheck = new Array();

function fnc_setPreInputName(param_value) {
	var_preInputName = param_value;
}
function fnc_setCheckFormular(param_name, param_value) {
	if(param_name){
		var_toCheck.push(param_name);

		var_valueCheck.push(param_value);

	}
}
function fnc_mkAlert(param_kind, param_value) {

	if(param_kind){
		if(param_kind == 'Url')
			alert('<p class="noticeIcon"> </p>'+obj_lang['alertTopUncomplete'],'<span class="bold">'+param_value +'</span> '+obj_lang['alertUrl']);
		else if(param_kind == 'EMail')
			alert('<p class="noticeIcon"> </p>'+obj_lang['alertTopUncomplete'],'<span class="bold">'+param_value +'</span> '+obj_lang['alertEmail']);
		else if(param_kind == 'Name' || param_kind == 'NickName')
			alert('<p class="noticeIcon"> </p>'+obj_lang['alertTopValue'],'<span class="bold">'+param_value +'</span> '+obj_lang['alertName']);
		else if(param_kind == 'Search')
			alert('<p class="noticeIcon"> </p>'+obj_lang['alertTopSearch'],'<span class="bold">'+param_value +'</span> '+obj_lang['alertSearch']);
	}
	else
		alert('<p class="noticeIcon"> </p>'+obj_lang['alertTopUncomplete'],'<span style="color:red;">*</span> '+obj_lang['alertBound']);
}
function fnc_chkSearchFormular() {
	if(window.document.getElementById("searchValue").value == "" || !window.document.getElementById("searchValue").value.match(/^[\w\-]+$/)){
		window.document.getElementById("searchValue").focus();
		fnc_mkAlert('Search',window.document.getElementById("searchValue").value);
		window.document.getElementById("searchValue").focus();
		return false;
	}
	return true;
}
function chkFormular () {
	for(index = var_toCheck.length - 1; index >=0; index-- ){
		if(var_toCheck[index] != 'Start' && var_valueCheck[index] == ""){
			if(var_toCheck[index] != 'Link'){
				if(window.document.getElementsByName(var_preInputName + "[" + var_toCheck[index] + "]")[0].value == ""){
					window.document.getElementsByName(var_preInputName + "[" + var_toCheck[index] + "]")[0].focus();
					fnc_mkAlert();
					window.document.getElementsByName(var_preInputName + "[" + var_toCheck[index] + "]")[0].focus();
					return false;
				}
			}
			else{
				if(window.document.getElementsByName("0")[0].value == "" && window.document.getElementsByName("[old_file]")[0].value == ""){
					window.document.getElementsByName("0")[0].focus();
					fnc_mkAlert();
					window.document.getElementsByName("0")[0].focus();
					return false;
				}
			}
		}
	}
	if(window.document.getElementsByName(var_preInputName + "[Url]" )){
		for(index = window.document.getElementsByName(var_preInputName + "[Url]" ).length - 1; index >=0; index-- ){
			if(window.document.getElementsByName(var_preInputName + "[Url]" )[index].value !="" && !window.document.getElementsByName(var_preInputName + "[Url]" )[index].value.match(/^((http|https)\:\/\/){1}([\w\-\/\.\[\]\&\?\=\,])+$/)){
				window.document.getElementsByName(var_preInputName + "[Url]" )[index].focus();
				fnc_mkAlert('Url', window.document.getElementsByName(var_preInputName + "[Url]" )[index].value);
				window.document.getElementsByName(var_preInputName + "[Url]" )[index].focus();
				return false;
			}

		}
	}
	if(window.document.getElementsByName(var_preInputName + "[EMail]" )){
		for(index = window.document.getElementsByName(var_preInputName + "[EMail]" ).length - 1; index >=0; index-- ){
			if(window.document.getElementsByName(var_preInputName + "[EMail]" )[index].value !="" && !window.document.getElementsByName(var_preInputName + "[EMail]" )[index].value.match(/^[_\.A-Za-z0-9\-]+@([A-Za-z0-9\-]+\.)+[a-z]{2,4}$/)){
				window.document.getElementsByName(var_preInputName + "[EMail]" )[index].focus();
				fnc_mkAlert('EMail', window.document.getElementsByName(var_preInputName + "[EMail]" )[index].value);
				window.document.getElementsByName(var_preInputName + "[EMail]" )[index].focus();
				return false;
			}

		}
	}
	if(window.document.getElementsByName(var_preInputName + "[Name]" ).length > 0){
		if(window.document.getElementsByName(var_preInputName + "[Name]" )[0].value !="" && !window.document.getElementsByName(var_preInputName + "[Name]" )[0].value.match(/^[\w\-]+$/)){
				window.document.getElementsByName(var_preInputName + "[Name]" )[0].focus();
				fnc_mkAlert('Name', window.document.getElementsByName(var_preInputName + "[Name]" )[0].value);
				window.document.getElementsByName(var_preInputName + "[Name]" )[0].focus();
				return false;
		}
	}
	if(window.document.getElementsByName(var_preInputName + "[NickName]" ).length > 0){
		if(window.document.getElementsByName(var_preInputName + "[NickName]" )[0].value !="" && !window.document.getElementsByName(var_preInputName + "[NickName]" )[0].value.match(/^[\w\-]+$/)){
				window.document.getElementsByName(var_preInputName + "[NickName]" )[0].focus();
				fnc_mkAlert('NickName', window.document.getElementsByName(var_preInputName + "[NickName]" )[0].value);
				window.document.getElementsByName(var_preInputName + "[NickName]" )[0].focus();
				return false;
		}
	}
	if(window.document.getElementsByName(var_preInputName + "[Delete]")[0]){
		if(window.document.getElementsByName(var_preInputName + "[Delete]")[0].checked){
			Check = confirm(obj_lang['checkDelete']);
			if(!Check)
				return false;
		}
	}
}
function chkRemove(param_lang){
	Check = confirm(obj_lang['checkRemove'+param_lang]);
	if(!Check)
		return false;
}
function chkDelete(){
	Check = confirm(obj_lang['checkDelete']);
	if(!Check)
		return false;
}