<!--
var validations = new Array();
// Define which validations to perform. Each array item
// holds the form field to validate, and the validation
// to be applied. This is the only party you need to
// customize in order to use the script in a new page!
validations[0]=["document.cadastrousuario.nome", "notblank"];
validations[1]=["document.cadastrousuario.email", "validemail"];

// Customize above array when used with a new page.
function isEmpty(s){
	if (s == null || s.length == 0)
	return true;
// The test returns true if there is at least one non-
// whitespace, meaning the string is not empty. If the
// test returns true, the string is empty.
	return !/\S/.test(s);
	}
function looksLikeEmail(field){
	var s = field.value;
	if (isEmpty(s)){
//alert("Email may not be empty");
	window.document.cadastrousuario.verifica.value='Preencha o campo email!';
	field.focus();
	return false;
	}
	if (/[^@]+@\w+/.test(s))
	return true;
//
//alert("E-mail not in valid form.");
	window.document.cadastrousuario.verifica.value='Email em formato inválido!';
	field.focus();
	return false;
	}
function isInteger(field){
	var s = field.value;
	if (isEmpty(s)){
//alert("Field cannot be empty");
	window.document.cadastrousuario.verifica.value='Preencha o campo '+ field.name +'!';
	field.focus();
	return false;
	}
	if (!(/^-?\d+$/.test(s))){
		if(field.name=="mes"){
		
		//verifica se é o campo mes por causa do acento
		window.document.cadastrousuario.verifica.value='O campo mês só pode conter números!';
		field.focus();
		}else{
		window.document.cadastrousuario.verifica.value='O campo '+ field.name +' só pode conter números!';
		field.focus();
		}
	return false;
	}
return true;
}

function validate(){
	//checa sempre antes se o campo de senha corresponde à confirmacao
	//inicia o lopp com as demais confirmacões
		var i;
		var checkToMake;
		var field;
		for (i = 0; i < validations.length; i++){
			field = eval(validations[i][0]);
			checkToMake = validations[i][1];
			switch (checkToMake){
			case 'notblank': if (isEmpty(field.value)){
			//alert("Field may not be empty");
			window.document.cadastrousuario.verifica.value='Preencha o campo '+ field.name +'!';
			field.focus();
			return false;
			}
			break;
			case 'validemail': if (!looksLikeEmail(field))
			return false;
			break;
			case 'isnumber': if (!isInteger(field))
			return false;
			}
		}
	
return true;
}


//-->

