function checkWholeForm(theForm) {
    var why = "";
    why += checkUsername(document.theForm.name.value);
	  why += checkEmail(document.theForm.email.value);
       why += checkPhonename(document.theForm.telephone.value);
		why += checkPhone(document.theForm.telephone.value);
		  if (why != "") {
       alert(why);
       return false;
    }
return true;
}
function checkUsername (strng) {
 var error = "";
 if (strng == "") {
    error = "Please enter your name.\n";
    }
	return error;
 }
 function checkPhonename (strng) {
 var error = "";
 if (strng == "") {
    error = "Please enter your phone number.\n";
    }
	return error;
 }
 function checkEmail(strng) {
var error = "";
var emailFilter=/^.+@.+\..{2,3}$/;
if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
}
var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
if (strng.match(illegalChars)) {
   error = "The email address contains illegal characters.\n";
}
return error;
}
function checkPhone(strng) {
var error = "";
var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
//strip out acceptable non-numeric characters
if (isNaN(parseInt(stripped))) {
   error = "The phone number contains illegal characters.";
}
if (!(stripped.length == 10)) {
	error = "The phone number is the wrong length. Make sure you included an area code.\n";
}
return error;
}
 