/* VALID EMAIL CHECK ========================================================= */
function checkemail(the_value) {
// Checks the email field for:
// 1. must be at least 6 characters long i.e. 1@3.56
// 2. cannot begin with a "@" or a "."
// 3. cannot end with a "@" or a "."
// 4. cannot have 2 "." in a row
// 5. cannot have ".@" nor "@."
// 6. must contain 1 "@" and at least 1 "."
// 7. must have 2 or 3 characters after the final "."
// 8. checks specified bad chars like commas
var amp1 = 0;
var dot1 = 0;
var postdot1 = 0;
if (the_value.length<6)
{return false}
if (the_value.charAt(0)=='.')
{return false}
if (the_value.charAt(the_value.length)=='.')
{return false}
if (the_value.charAt(0)=='@')
{return false}
if (the_value.charAt(the_value.length)=='@')
{return false}
amp1 = 0;
dot1 = 0;
postdot1 = 0;
for(var i = 0; i < the_value.length; i++) {
if (the_value.charAt(i)==',') // add bad chars here
{return false}
if (the_value.charAt(i)=='@')
{if (the_value.charAt(i-1)=='.')
{return false}
amp1=amp1+1}
if (the_value.charAt(i)=='.')
{if (the_value.charAt(i-1)=='.')
{return false}
if (the_value.charAt(i-1)=='@')
{return false}
if (dot1>0)
{dot1=0;
postdot1=0}
dot1=dot1+1}
if (dot1>0)
{postdot1=postdot1+1}
}
if (amp1!=1)
{return false}
if (dot1<1)
{return false}
if (postdot1!=5 && postdot1!=4 && postdot1!=3)
{return false}
return true;
}
/* ========================================================= */
