
<!--
function Form1_Validator(theForm)
{

var alertsay = ""; // define for long lines


// check to see if the field is blank
if (theForm.name.value == "")
{
alert("O campo Nome é obrigatório.");
theForm.name.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.name.value.length < 3)
{
alert("Pelo menos 3 caracteres são necessários para preenchimento do 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 = "ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ abcdefghijklmnopqrstuvwxyzåäö-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("Somente letras e números são válidos para o campo \"Nome\". Por favor, redigite.");
theForm.name.focus();
return (false);
}


if (theForm.text.value == "")
{
alert("Você deve digitar um texto.");
theForm.text.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.text.value.length < 3)
{
alert("Pelo menos 3 caracteres são necessários para preenchimento do campo \"Texto\".");
theForm.text.focus();
return (false);
}



if (theForm.title.value == "")
{
alert("Você deve digitar o título do anúncio.");
theForm.title.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.title.value.length < 3)
{
alert("Pelo menos 3 caracteres são necessários para preenchimento do campo \"Título\".");
theForm.title.focus();
return (false);
}

// require at least 5 characters in the password field
if (theForm.Password.value.length < 5)
{
alert("Pelo menos 5 caracteres são necessários para preenchimento do campo \"Senha\".");
theForm.Password.focus();
return (false);
}

// check if both password fields are the same
if (theForm.Password.value != theForm.Password2.value)
{
	alert("Os campos de Senha não foram preenchidos iguais.");
	theForm.Password2.focus();
	return (false);
}

// allow only 3000 characters maximum in the text field
if (theForm.text.value.length > 3000)
{
alert("O campo pode ter no máx. 3000 caracteres.");
theForm.text.focus();
return (false);
}

// check if no drop down has been selected concerning INTEREST
if (theForm.interest.selectedIndex < 0)
{
alert("Selecione uma das opções de \"Interesse\".");
theForm.interest.focus();
return (false);
}

// check if the first drop down is selected, if so, invalid selection
if (theForm.interest.selectedIndex == 0)
{
alert("O primeiro \"Interesse\" não é uma opção válida.");
theForm.interest.focus();
return (false);
}


// check if no drop down has been selected
if (theForm.state.selectedIndex < 0)
{
alert("Selecione uma das opções de \"Estado\".");
theForm.state.focus();
return (false);
}

// check if the first drop down is selected, if so, invalid selection
if (theForm.state.selectedIndex == 0)
{
alert("O primeiro \"Estado\" não é uma opção válida.");
theForm.state.focus();
return (false);
}


// check if no drop down has been selected
if (theForm.category.selectedIndex < 0)
{
alert("Selecione uma das opções da \"Categoria\".");
theForm.interest.focus();
return (false);
}

// check if the first drop down is selected, if so, invalid selection
if (theForm.category.selectedIndex == 0)
{
alert("A primeira \"Categoria\" não é uma opção válida.");
theForm.category.focus();
return (false);
}


// check if email field is blank
if (theForm.Email.value == "")
{
alert("Entre com um \"e-mail\" válido.");
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 campo de \"e-mail\" deve conter um \"@\" e um \".\".");
theForm.Email.focus();
return (false);
}


// check if numbers field is blank
if (theForm.phone.value == "")
{
alert("Preencha o campo \"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("Somente caracteres numéricos são válidos para o campo \"Telefone\".");
theForm.phone.focus();
return (false);
}



// alert if the box is NOT checked
if (!theForm.checkbox1.checked)
{
alertsay = "Só lembrando que você deve aceitar as informações do formulário para validar o anúncio"
alert(alertsay);
}

}



//-->
