// email
function checkEmail (strng, showAlert) {
	var error="";
    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error += "Please enter a valid email address.\n";
       if (showAlert) {
       		alert(error);
       		return false;
       }
    }
    else {
	   //test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
       if (strng.match(illegalChars)) {
          error += "The email address contains illegal characters.\n";
          if (showAlert) alert(error);
       }
    }
    return error;    
}


// phone number - strip out delimiters and check for 10 digits
function checkPhone (strng, showAlert) {
    var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    var error = "";
    if (isNaN(parseInt(stripped))) {
       error += "The phone number contains non-numeric characters. Please enter numeric phone number only.\n";
       if (showAlert) {
       		alert(error);
       		return false;
       }
    }
    if (stripped.length != 10) {
	   error += "The phone number is the wrong length. Make sure you included an area code.\n";
	   if (showAlert) alert(error);
    } 
    return error;
}

