function validate()
{
invalidChars="()<> /:,;"
email=document.myform.Email.value;

if (document.myform.Name.value=="")
{alert("Please enter your name");
return false;
}

if (document.myform.Name.value.length < 2)
{alert("Please enter your full name");
return false;
}

if (document.myform.Email.value=="")
{alert("Please enter your email address");
return false;
}

for(i=0;i<invalidChars.length;i++)
{
badChar=invalidChars.charAt(i)
if(email.indexOf(badChar,0)>-1)
{
alert ("invalid email address. You can't use space / : , or ; in an email address");
return false;
}

}
badPos=email.indexOf("@",0)
atPos=email.indexOf("@",1)

if(!badPos)
{alert("Invalid email address. You cannot start with @");
return false;
}

if(atPos==-1)
{alert("Invalid email address. You haven't included @");
return false;
}

if (email.indexOf("@",atPos+1)>1)
{alert("Invalid email address. You have too many @ in your address");
return false;
}

periodPos=email.indexOf(".",atPos)
if (periodPos==-1)
{alert("invalid email address. There is no . in your email address");
return false;
}
badPos=periodPos+1
charPos=email.charAt(badPos)
charComp="."

if (charPos==charComp)
{alert ("Invalid email address. You have .. in your address.");
return false;
} 

if (periodPos+3 > email.length)
{alert("Invalid email address. You don't have enough characters after .");
return false;
}

if (document.myform.Subject.value=="")
{alert("Please enter a subject");
return false;
}

if (document.myform.Comments.value=="")
{alert("Please enter some comments");
return false;
}


return true;
}

function forumvalidate()
{
test = document.myform.Postcode.value; 
 size = test.length
 test = test.toUpperCase(); //Change to uppercase
 while (test.slice(0,1) == " ") //Strip leading spaces
  {test = test.substr(1,size-1);size = test.length
  }
 while(test.slice(size-1,size)== " ") //Strip trailing spaces
  {test = test.substr(0,size-1);size = test.length
  }
 document.myform.Postcode.value = test; //write back to form field
 if (size < 6 || size > 8){ //Code length rule
  alert( "This is not a valid postcode - wrong length");
  return false;
  }
 if (!(isNaN(test.charAt(0)))){ //leftmost character must be alpha character rule
   alert(test + " is not a valid postcode - cannot start with a number");
   return false;
  }
 if (isNaN(test.charAt(size-3))){ //first character of inward code must be numeric rule
   alert(test + " is not a valid postcode - alpha character in wrong position");
   return false;
  }
 if (!(isNaN(test.charAt(size-2)))){ //second character of inward code must be alpha rule
   alert(test + " is not a valid postcode - number in wrong position");
   return false;
  }
 if (!(isNaN(test.charAt(size-1)))){ //third character of inward code must be alpha rule
   alert(test + " is not a valid postcode - number in wrong position");
   return false;
  }
 if (!(test.charAt(size-4) == " ")){//space in position length-3 rule
   alert(test + " is not a valid postcode - no space or space in wrong position");
   return false;
   }
 count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
 if (count1 != count2){//only one space rule
   alert(test + " is not a valid postcode - only one space allowed");
   return false;
  }


invalidChars="()<> /:,;"
email=document.myform.Email.value;

if (document.myform.Name.value=="")
{alert("Please enter your name");
return false;
}

if (document.myform.Name.value.length < 2)
{alert("Please enter your full name");
return false;
}

if (document.myform.Organisation.value=="")
{alert("Please enter the name of your organisation");
return false;
}
if (document.myform.Area.value=="")
{alert("Please enter your area code");
return false;
}

if (document.myform.Telephone.value=="")
{alert("Please enter your telephone number");
return false;
}
if (document.myform.Postcode.value=="")
{alert("Please enter your postcode");
return false;
}


if (document.myform.Email.value=="")
{alert("Please enter your email address");
return false;
}



for(i=0;i<invalidChars.length;i++)
{
badChar=invalidChars.charAt(i)
if(email.indexOf(badChar,0)>-1)
{
alert ("invalid email address. You can't use space / : , or ; in an email address");
return false;
}

}
badPos=email.indexOf("@",0)
atPos=email.indexOf("@",1)

if(!badPos)
{alert("Invalid email address. You cannot start with @");
return false;
}

if(atPos==-1)
{alert("Invalid email address. You haven't included @");
return false;
}

if (email.indexOf("@",atPos+1)>1)
{alert("Invalid email address. You have too many @ in your address");
return false;
}

periodPos=email.indexOf(".",atPos)
if (periodPos==-1)
{alert("invalid email address. There is no . in your email address");
return false;
}
badPos=periodPos+1
charPos=email.charAt(badPos)
charComp="."

if (charPos==charComp)
{alert ("Invalid email address. You have .. in your address.");
return false;
} 

if (periodPos+3 > email.length)
{alert("Invalid email address. You don't have enough characters after .");
return false;
}



return true;


}



function registrationvalidate()
{
if (document.myform.Postcode.value=="")
{alert("Please enter your postcode");
return false;
}

test = document.myform.Postcode.value; 
 size = test.length
 test = test.toUpperCase(); //Change to uppercase
 while (test.slice(0,1) == " ") //Strip leading spaces
  {test = test.substr(1,size-1);size = test.length
  }
 while(test.slice(size-1,size)== " ") //Strip trailing spaces
  {test = test.substr(0,size-1);size = test.length
  }
 document.myform.Postcode.value = test; //write back to form field
 if (size < 6 || size > 8){ //Code length rule
  alert( "This is not a valid postcode - wrong length");
  return false;
  }
 if (!(isNaN(test.charAt(0)))){ //leftmost character must be alpha character rule
   alert(test + " is not a valid postcode - cannot start with a number");
   return false;
  }
 if (isNaN(test.charAt(size-3))){ //first character of inward code must be numeric rule
   alert(test + " is not a valid postcode - alpha character in wrong position");
   return false;
  }
 if (!(isNaN(test.charAt(size-2)))){ //second character of inward code must be alpha rule
   alert(test + " is not a valid postcode - number in wrong position");
   return false;
  }
 if (!(isNaN(test.charAt(size-1)))){ //third character of inward code must be alpha rule
   alert(test + " is not a valid postcode - number in wrong position");
   return false;
  }
 if (!(test.charAt(size-4) == " ")){//space in position length-3 rule
   alert(test + " is not a valid postcode - no space or space in wrong position");
   return false;
   }
 count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
 if (count1 != count2){//only one space rule
   alert(test + " is not a valid postcode - only one space allowed");
   return false;
  }

invalidChars="()<> /:,;"
email=document.myform.Email.value;

if (document.myform.Firstname.value=="")
{alert("Please enter your first name");
return false;
}

if (document.myform.Lastname.value=="")
{alert("Please enter your name");
return false;
}

if (document.myform.Lastname.value.length < 2)
{alert("Please enter your full name");
return false;
}


if (document.myform.Area.value=="")
{alert("Please enter your area code");
return false;
}

if (document.myform.Telephone.value=="")
{alert("Please enter your telephone number");
return false;
}

if (document.myform.Email.value=="")
{alert("Please enter your email address");
return false;
}

for(i=0;i<invalidChars.length;i++)
{
badChar=invalidChars.charAt(i)
if(email.indexOf(badChar,0)>-1)
{
alert ("invalid email address. You can't use space / : , or ; in an email address");
return false;
}

}
badPos=email.indexOf("@",0)
atPos=email.indexOf("@",1)

if(!badPos)
{alert("Invalid email address. You cannot start with @");
return false;
}

if(atPos==-1)
{alert("Invalid email address. You haven't included @");
return false;
}

if (email.indexOf("@",atPos+1)>1)
{alert("Invalid email address. You have too many @ in your address");
return false;
}

periodPos=email.indexOf(".",atPos)
if (periodPos==-1)
{alert("invalid email address. There is no . in your email address");
return false;
}
badPos=periodPos+1
charPos=email.charAt(badPos)
charComp="."

if (charPos==charComp)
{alert ("Invalid email address. You have .. in your address.");
return false;
} 

if (periodPos+3 > email.length)
{alert("Invalid email address. You don't have enough characters after .");
return false;
}



return true;
}



