
<!--
function Form1_Validator(theForm)
{

var alertsay = ""; // define for long lines


// check to see if the field is blank
if (theForm.namn.value == "")
{
alert("Du måste ange ditt namn.");
theForm.namn.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.namn.value.length < 3)
{
alert("Du måste ange minst 3 bokstäver i ditt namn");
theForm.namn.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åäö-";
var checkStr = theForm.namn.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("Du har angivit ett felaktigt tecken i ditt namn.");
theForm.namn.focus();
return (false);
}

// check if email field is blank
if (theForm.epost.value == "")
{
alert("Ange en epost adress.");
theForm.epost.focus();
return (false);
}


// test if valid email address, must have @ and .
var checkEmail = "@.";
var checkStr = theForm.epost.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("Vänligen ange en korrekt epostadress.");
theForm.epost.focus();
return (false);
}

if (theForm.inlagg.value == "")
{
alert("Du måste skriva en hälsning i gästboken.");
theForm.inlagg.focus();
return (false);
}

// require at least 3 characters be entered in TEXT 
if (theForm.inlagg.value.length < 15)
{
alert("Meddelandet du skrev är för kort");
theForm.inlagg.focus();
return (false);
}

// allow only 1000 characters maximum in the text field
if (theForm.inlagg.value.length > 1000)
{
alert("Meddelandet du skrivit är för långt. Du får inte skriva mer än 1000 tecken.");
theForm.inlagg.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åäö-";
var checkStr = theForm.inlagg.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("Du har angivit ett felaktigt tecken i ditt inlägg.");
theForm.inlagg.focus();
return (false);
}


// alert if the box is NOT checked
if (!theForm.godkann.checked)
{
alertsay = "Du måste godkänna att hälsningen publiceras här på sajten."
alert(alertsay);
theForm.godkann.focus();
return (false);
}

}



//-->
