function notEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
	}
	return true;
}

function notEqual(elem, elemtwo, helperMsg){
	if(elem.value != elemtwo.value){
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
	}
	return true;
}

function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isAlphabet(elem, helperMsg){ //NON UTILIZZARLO PERCHE NON ACCETTA i CARATTERI ACCENTATI
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isAlphanumeric(elem, helperMsg){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function pwdlengthRestriction(elem, min, max){
	var uInput = elem.value;
	if(uInput.length >= min && uInput.length <= max){
		return true;
	}else{
		alert("Please enter between " +min+ " and " +max+ " characters for the password. \nPor favor indicar entre " +min+ " e " +max+ " caracteres para a senha.");
		elem.focus();
		return false;
	}
}

function answerlengthRestriction(elem, min, max){
	var uInput = elem.value;
	if(uInput.length >= min && uInput.length <= max){
		return true;
	}else{
		alert("Por favor indicar entre " +min+ " e " +max+ " caracteres para a resposta.");
		elem.focus();
		return false;
	}
}

function madeSelection(elem, helperMsg){
	if(elem.value == "Selecione .."){
		alert(helperMsg);
		elem.focus();
		return false;
	}else{
		return true;
	}
}




function iscliqued(elem, helperMsg){
	if(elem.checked){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function emailValidator(elem, helperMsg){
	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 isCPF(elem, helperMsg){
	var cpf = /^([0-9]{3}\.){2}[0-9]{3}-[0-9]{2}$/;
	if(elem.value.match(cpf)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isCEP(elem, helperMsg){
	var cep = /^[0-9]{5}-[0-9]{3}$/;
	if(elem.value.match(cep)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}
      

