
<!--
function Form1_Validator(theForm)
{

var alertsay = ""; // define for long lines


// check to see if the field is blank
if (theForm.name.value == "")
{
alert("Você precisa informar seu nome.");
theForm.name.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.name.value.length < 3)
{
alert("Por favor insira pelo menos 3 caracteres no campo nome");
theForm.name.focus();
return (false);
}

// allow ONLY alphanumeric keys, no symbols or punctuation
// this can be altered for any "checkOK" string you desire
var checkOK = "AÁÃBCDEÉÊFGHIÍJKLMNOÓÔÕPQRSTUÚVWXYZ aáãbcdeéêfghiíjklmnoóôõpqrstuúvwxyz-0123456789";
var checkStr = theForm.name.value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("Insira apenas caracteres alfa-numéricos no campo \"name\" .");
theForm.name.focus();
return (false);
}


if (theForm.text.value == "")
{
alert("Você precisa digitar um texto.");
theForm.text.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.text.value.length < 3)
{
alert("Por favor, digite pelo menos 3 caracteres no campo \"text\".");
theForm.text.focus();
return (false);
}



if (theForm.title.value == "")
{
alert("Você precisa dar um título ao anúncio.");
theForm.title.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.title.value.length < 3)
{
alert("Por favor, digite pelo menos 3 caracteres no campo \"title\".");
theForm.title.focus();
return (false);
}




// require at least 5 characters in the password field
if (theForm.Password.value.length < 5)
{
alert("Por favor, digite pelo menos 5 caracteres no campo \"Password\".");
theForm.Password.focus();
return (false);
}

// check if both password fields are the same
if (theForm.Password.value != theForm.Password2.value)
{
	alert("As duas senhas não são as mesmas.");
	theForm.Password2.focus();
	return (false);
}

// allow only 1000 characters maximum in the text field
if (theForm.text.value.length > 3000)
{
alert("Por favor insira até 3000 caracteres no campo de texto.");
theForm.text.focus();
return (false);
}

// check if no drop down has been selected concerning INTEREST
if (theForm.interest.selectedIndex < 0)
{
alert("Por favor selecione uma das modalidades de anúncio.");
theForm.interest.focus();
return (false);
}

// check if the first drop down is selected, if so, invalid selection
if (theForm.interest.selectedIndex == 0)
{
alert("Esta opção não é válida.");
theForm.interest.focus();
return (false);
}


// check if no drop down has been selected
if (theForm.state.selectedIndex < 0)
{
alert("Selecione um Estado.");
theForm.state.focus();
return (false);
}

// check if the first drop down is selected, if so, invalid selection
if (theForm.state.selectedIndex == 0)
{
alert("Esta opção não é válida.");
theForm.state.focus();
return (false);
}


// check if no drop down has been selected
if (theForm.category.selectedIndex < 0)
{
alert("Selecione uma categoria.");
theForm.interest.focus();
return (false);
}

// check if the first drop down is selected, if so, invalid selection
if (theForm.category.selectedIndex == 0)
{
alert("Esta opção não é válida.");
theForm.category.focus();
return (false);
}


// check if email field is blank
if (theForm.Email.value == "")
{
alert("Informe o seu e-mail.");
theForm.Email.focus();
return (false);
}


// test if valid email address, must have @ and .
var checkEmail = "@.";
var checkStr = theForm.Email.value;
var EmailValid = false;
var EmailAt = false;
var EmailPeriod = false;

for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkEmail.length;  j++)
{
if (ch == checkEmail.charAt(j) && ch == "@")
EmailAt = true;
if (ch == checkEmail.charAt(j) && ch == ".")
EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
if (EmailAt && EmailPeriod)
{
		EmailValid = true
		break;
	}
}
if (!EmailValid)
{
alert("O e-mail informado não é válido.");
theForm.Email.focus();
return (false);
}


// check if numbers field is blank
if (theForm.phone.value == "")
{
alert("Você precisa informar seu telefone.");
theForm.phone.focus();
return (false);
}

// only allow numbers to be entered
var checkOK = "012345 -6789";
var checkStr = theForm.phone.value;
var allValid = true;
var allNum = "";
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
if (!allValid)
{
alert("Por favor insira apenas caracteres numéricos no campo telefone.");
theForm.phone.focus();
return (false);
}


// alert if the box is NOT checked
if (!theForm.checkbox1.checked)
{
alertsay = "Lembramos que você tem de aprovar os termos de uso deste formulário."
alert(alertsay);
}

// alert se extesao diferente de jpg
var valido = "jpg";  
var campo = theForm.FILE1.value;
var ext = campo.substring(campo.length-3,campo.length);  

 if (ext!=valido) {  
	 alert('Este tipo de arquivo nao é permitido: '+ext);  
	 return false;  
 }  

}
//-->