
function validEmail(field, txt){
	var a = document.getElementById(field);
	var str = a.value;
	var patt= /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
	var check = patt.test(str);	
	if(check){
		return false;
	}else{
		showErrorMesasge(txt);
		return true;
	}
}
/*
function checkFileType(fileName, fileTypes, txt) {
	var comp = document.getElementById(fileName);
	var a = comp.value;
	dots = a.split(".")
	fileType = "." + dots[dots.length-1];
	if(fileTypes.join(".").indexOf(fileType) != -1) 
	{ 
		// if value Matches with given inputs
		return false;
	}else{
		// Wrong File
		comp.focus(showError(comp));
		showTxt(txt);
		return true;
	}
}
*/
function checkEmpty(field, txt){
	var comp = document.getElementById(field);
	var patt1 = /^\W/;
	if(comp.value == ""){
		showErrorMesasge(txt);
		return true;		
	}else if(patt1.test(comp.value)){
		comp.select();
		showErrorMesasge("Non-Word character are not allowed at the start of the text");
		return true;		
	}else{
		return false;
	}
}

function non_char(field, txt){
	var comp = document.getElementById(field);
	var patt1 = /^\W/;
	if(patt1.test(comp.value)){
		comp.select();
		showErrorMesasge(txt);
		return true;		
	}else{
		return false;
	}
}

function checkList(field, txt){
	var comp = document.getElementById(field);
	if(comp.selectedIndex == 0){
		showErrorMesasge(txt);		
		return true;
	}
}

function showErrorMesasge(txt){
	var div = document.getElementById('error');
	div.style.display='block';
	var msg = document.getElementById('error_message');
	msg.innerHTML = txt;		
}

function clearErrorMessage(){
	var div = document.getElementById('error');
	div.style.display='none';
	var msg = document.getElementById('error_message');
	msg.innerHTML = '';		
}