

<!--
function Form1_Validator(theForm)
{

var alertsay = ""; // define for long lines


// check to see if the field is blank
if (theForm.name.value == "")
{
alert("Du måste skriva in ett namn");
theForm.name.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.name.value.length < 2)
{
alert("Använd minst 2 bokstäver i ditt \"namn\"");
theForm.name.focus();
return (false);
}


if (theForm.text.value == "")
{
alert("Du måste skriva en annonstext");
theForm.text.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.text.value.length < 3)
{
alert("Använd minst 3 tecken i fältet \"text\"");
theForm.text.focus();
return (false);
}



if (theForm.title.value == "")
{
alert("Du måste skriva in en annonsrubrik");
theForm.title.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.title.value.length < 3)
{
alert("Använd minst 3 tecken i din annonsrubrik");
theForm.title.focus();
return (false);
}

// allow only 1000 characters maximum in the text field
if (theForm.text.value.length > 3000)
{
alert("Du får inte använda över 3000 tecken i annonstexten");
theForm.text.focus();
return (false);
}

// check if no drop down has been selected concerning INTEREST
if (theForm.typ.selectedIndex < 0)
{
alert("Välj annonstyp på din annons");
theForm.typ.focus();
return (false);
}

// check if the first drop down is selected, if so, invalid selection
if (theForm.typ.selectedIndex == 0)
{
alert("Välj annonstyp på din annons");
theForm.typ.focus();
return (false);
}


// check if no drop down has been selected
if (theForm.Omrade.selectedIndex < 0)
{
alert("Välj ett område");
theForm.Omrade.focus();
return (false);
}

// check if the first drop down is selected, if so, invalid selection
if (theForm.Omrade.selectedIndex == 0)
{
alert("Välj ett område");
theForm.Omrade.focus();
return (false);
}


// check if no drop down has been selected
if (theForm.Kategori.selectedIndex < 0)
{
alert("Välj en kategori");
theForm.Kategori.focus();
return (false);
}

// check if the first drop down is selected, if so, invalid selection
if (theForm.Kategori.selectedIndex == 0)
{
alert("Välj en kategori");
theForm.Kategori.focus();
return (false);
}


// check if email field is blank
if (theForm.Email.value == "")
{
alert("Skriv måste ange en fungerade e-post adress");
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("Du måste ange en fungerande e-post adress");
theForm.Email.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("Använd endast siffror i ditt telefonnummer");
theForm.phone.focus();
return (false);
}

// require at least 5 characters in the password field
if (theForm.Password.value.length < 5)
{
alert("Använd minst 5 tecken i ditt lösenord");
theForm.Password.focus();
return (false);
}


}



//-->
