//form validation script by Chris Dowdell
//see www.heartandparcel.co.uk
//Heart and Parcel form validation
//If you use this script please leave comments intact

function Form1_Validator(newssignup)
{


// check to see if the field is blank
if (newssignup.Email.value == "")
{
alert("You must enter an email address.");
newssignup.Email.focus();
return (false);
}

// test if valid email address, must have @ and .
var checkEmail = "@.";
var checkStr = newssignup.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("The \"emails\" field must contain an \"@\" and a \".\".");
newssignup.Email.focus();
return (false);
}




// because this is a sample page, don't allow to exit to the post action
// comes in handy when you are testing the form validations and don't
// wish to exit the page
alertsay = "All required fields completed. "
alertsay = alertsay + "We will now submit your form."
alert(alertsay);
return (true);
// replace the above with return(true); if you have a valid form to submit to
}