function checkString (strng, type) {
 var error = "";
 if (strng == "") {
    error = "You didn't enter a ";
	error += type;
	error += ".\n";
 }
 return error;
}

function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an email address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}


// phone number - strip out delimiters and check for 10 digits

function checkPhone (strng, type) {
	var error = "";
	
	var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    	if (isNaN(parseInt(stripped))) {
    	   error = "The ";
		   error += type;
		   error += " contains illegal characters.";
  		}
    	if (!(stripped.length == 10)) {
			error = "The ";
			error += type;
			error+= " is the wrong length. Make sure you included an area code.\n";
    	
		} 
		
	if (strng == "") {
   		error = "You didn't enter a ";
		error += type;
		error += ".\n";
	}
	return error;
}

// valid selector from dropdown list

function checkDropdown(choice, type) {
	var error = "";
	if (choice == 0) {
		error = "You didn't choose an option from the ";
		error += type;
		error += " list.\n";
    }    
	return error;
}   
