
function checkEmail (strng) {
var error="";
 var emailFilter=/^.+@.+\..{2,3}$/;
var illegalChars= "/[\(\)\<\>\,\;\:\\\"\[\]]/";
if (strng == "") {
   error = "Please enter an Email address.\n";
}

   
 else if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid Email address.\n";
    }
    else if (strng.match(illegalChars)){
//test email for illegal characters
         error = "The Email address contains unprocessable characters.\n";
       }

return error;    
}

function checkComments (strng) {
var error = "";
var illegalChars= /[\<\>\[\]\%\#\^\*\=]/;
if (strng == "") {
   error = "Please enter a message.\n";
}
else if (illegalChars.test(strng)) { 
       error = "Not able process the message text. Please try again without any special characters. We appreciate your inquiries or comments.\n";
    }
 return error;
}


function checkWholeForm(theForm) {
    var why = "";
    
    why += checkEmail(theForm.email.value);
   	why += checkComments(theForm.message.value);
   
   if (why != "") {
       alert(why);
       return false;
    }
return true;
}
