//http://www.w3schools.com/js/js_form_validation.asp
//Use the following in the FORM tag: onsubmit="return validate_form(this);"
//make sure form fields have a NAME parameter.
//In the head, create a validate_form function, e.g.:
/*
function validate_form(thisform)
{
with (thisform)
{
if (validate_email(email,"Not a valid e-mail address!")==false)
  {email.focus();return false}
if (validate_required(email,"Not a valid e-mail address!")==false)
  {email.focus();return false}
}
}
*/

// field must not be empty.
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false}
else {return true}
}
}

//field must be email address
function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false}
else {return true}
}
}