
<!--
function Form1_Validator(theForm)
{

var alertsay = ""; // define for long lines


// check to see if the field is blank
if (theForm.name.value == "")
{
alert("Digite o seu nome.");
theForm.name.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.name.value.length < 3)
{
alert("Digite no mínimo 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 = "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("Por favor entre somente com caracteres numéricos para este campo");
theForm.name.focus();
return (false);
}


if (theForm.text.value == "")
{
alert("Digite a mensagem do anúncio.");
theForm.text.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.text.value.length < 3)
{
alert("Por favor digite no mínimo 3 caracteres neste campo");
theForm.text.focus();
return (false);
}



if (theForm.title.value == "")
{
alert("Digite um título.");
theForm.title.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.title.value.length < 3)
{
alert("Por favor digite no mínimo 3 caracters neste campo");
theForm.title.focus();
return (false);
}




// require at least 5 characters in the password field
if (theForm.Password.value.length < 5)
{
alert("Por favor digite no mínimo 5 caracters neste campo.");
theForm.Password.focus();
return (false);
}

// check if both password fields are the same
if (theForm.Password.value != theForm.Password2.value)
{
	alert("As duas senhas devem ser iguais.");
	theForm.Password2.focus();
	return (false);
}

// allow only 1000 characters maximum in the text field
if (theForm.text.value.length > 3000)
{
alert("Por favor digite no máximo 3000 caracters neste campo.");
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 opção 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("A primeira opção deste campo não é válida.");
theForm.interest.focus();
return (false);
}


// check if no drop down has been selected
if (theForm.state.selectedIndex < 0)
{
alert("Por favor 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("A primeira opção deste campo não é válida.");
theForm.state.focus();
return (false);
}


// check if no drop down has been selected
if (theForm.category.selectedIndex < 0)
{
alert("Por favor 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("A primeira opção deste campo não é válida.");
theForm.category.focus();
return (false);
}


// check if email field is blank
if (theForm.Email.value == "")
{
alert("Por favor digite 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 \"email\" deve conter \"@\" e \".\".");
theForm.Email.focus();
return (false);
}


// check if numbers field is blank
if (theForm.phone.value == "")
{
alert("Digite seu telefone neste campo, não use . ou , use - para separar os números");
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("Digite somente números neste campo");
theForm.phone.focus();
return (false);
}



// alert if the box is NOT checked
if (!theForm.checkbox1.checked)
{
alertsay = "Lembre-se você irá receber um e-mail solicitando aprovação dos dados aqui digitados, não esqueça de validar pois só assim seu anúncio será publicado em nosso portal."
alert(alertsay);
}

}



//-->