function checkForm(theForm) {
    var why = "";  
    why += checkText(theForm.senderName.value, "your name.");
    why += checkEmail(theForm.senderEmail.value);
	why += checkText(theForm.senderPhone.value, "your phone.");
    why += checkText(theForm.recipEmails.value, "at least one recipient email address.");
    
    if (why != "") {
       alert(why);
       return false;
    }
 
return true;
}


function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "Please enter a valid 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;    
}

function checkText (strng, formfield) {
 var error = "";
 if (strng == "") {
    error = "Please enter " + formfield + "\n";
 }
 return error;
 }
