function notEmpty(elem, helperMsg, div){
	if (elem!=null){
		if(elem.value.length == 0){
			g(div).innerHTML = helperMsg;
			g(div).style.visibility = 'visible';
			elem.focus(); // set the focus to this input
			return false;
		}
		return true;
	}
	return true;
}

function isNumeric(elem, helperMsg, div){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		g(div).innerHTML = helperMsg;
		g(div).style.visibility = 'visible';
		elem.focus();
		return false;
	}
}

function isAlphabet(elem, helperMsg, div){
	var alphaExp = /^[a-zA-Z ]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		g(div).innerHTML = helperMsg;
		g(div).style.visibility = 'visible';
		elem.focus();
		return false;
	}
}

function isAlphabetNospc(elem, helperMsg, div){
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		g(div).innerHTML = helperMsg;
		g(div).style.visibility = 'visible';
		elem.focus();
		return false;
	}
}

function isAlphanumeric(elem, helperMsg, div){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		g(div).innerHTML = helperMsg;
		g(div).style.visibility = 'visible';
		elem.focus();
		return false;
	}
}

function lengthRestriction(elem, min, max, div){
	var uInput = elem.value;
	if(uInput.length >= min && uInput.length <= max){
		return true;
	}else{
		g(div).innerHTML = helperMsg;
		g(div).style.visibility = 'visible';
		elem.focus();
		return false;
	}
}

function madeSelection(elem, helperMsg, div){
	if(elem.value == ""){
		g(div).innerHTML = helperMsg;
		g(div).style.visibility = 'visible';
		alert(helperMsg);
		return false;
	}else{
		return true;
	}
}

function emailValidator(elem, helperMsg, div){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function dateValidator(elem, helperMsg, div){
	var validformat=/^\d{2}\/\d{2}\/\d{4}$/;
	var returnval=false;
	
	if (!validformat.test(elem.value)){
		returnval=false;
	}
	else{ 
		var dayfield=elem.value.split("/")[0];
		var monthfield=elem.value.split("/")[1];
		var yearfield=elem.value.split("/")[2];
		var dayobj = new Date(yearfield, monthfield-1, dayfield);
		
		if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield)){
			returnval=false;
		}
		else{
			returnval=true;
		}
	}
	
	if (returnval==false) {
		g(div).innerHTML = helperMsg;
		g(div).style.visibility = 'visible';
		elem.focus();
	}
	return returnval
}