function checkWholeForm(theForm) {
    var why = "";
    why += checkUsername(document.theForm.name.value);
     why += checkState(document.theForm.state.value);
      why += checkCityname(document.theForm.city.value);
	why += checkPhonename(document.theForm.phone.value);
	 why += checkZipcodename(document.theForm.zipcode.value);
	  why += checkEmail(document.theForm.email.value);
	   why += checkPhone(document.theForm.phone.value);
	    why += checkZipcode(document.theForm.zipcode.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 checkState (strng) {
 var error = "";
 if (strng == "") {
    error = "Please enter your state.\n";
    }
	return error;
 }
 function checkCityname (strng) {
 var error = "";
 if (strng == "") {
    error = "Please enter your city.\n";
    }
	return error;
 }
 function checkPhonename (strng) {
 var error = "";
 if (strng == "") {
    error = "Please enter your phone number.\n";
    }
	return error;
 }
 function checkZipcodename (strng) {
 var error = "";
 if (strng == "") {
    error = "Please enter your zip code.\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;
}
 function checkZipcode(strng) {
var error = "";
var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
//strip out acceptable non-numeric characters
if (isNaN(parseInt(stripped))) {
   error = "The zip code contains illegal characters.";
}
if (!(stripped.length == 5)) {
	error = "The zip code is the wrong length. Make sure it is five digits.\n";
}
return error;
}
