function validateForm(theForm) {
var fld = theForm.custName;
var fld2 = theForm.custEmail;
var fld3 = theForm.custComments;
 var error = "";
    
    if (fld.value == "") {
        fld.style.background = 'Yellow'; 
        alert("Please enter your name");
    	return false;
	} 
	if (fld.value.length < 1 || fld.value.length > 100) {
        fld.style.background = 'Yellow'; 
        alert('The name should be no more than 100 characters.');
    	return false;
	}
	     
    var tfld = trim(fld2.value);// value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
    
    if (fld2.value == "") {
        fld2.style.background = 'Yellow';
        alert("You didn't enter an email address.\n");
		return false;
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld2.style.background = 'Yellow';
        alert("Please enter a valid email address.\n");
		return false;
    } else if (fld2.value.match(illegalChars)) {
        fld2.style.background = 'Yellow';
        alert("The email address contains illegal characters.\n");
		return false;
    } else {
        fld2.style.background = 'White';
    }    
	 if (fld3.value == "") {
        fld3.style.background = 'Yellow'; 
        alert("Please enter some comments");
    	return false;
	} 
	if (fld3.value.length < 1 || fld3.value.length > 200) {
        fld3.style.background = 'Yellow'; 
        alert('The comments should be no more than 200 characters.');
    	return false;
	}      
    
}
function validateForm2(theForm) {
var fld = theForm.custName;
var fld2 = theForm.custEmail;

 var error = "";
    
    if (fld.value == "") {
        fld.style.background = 'Yellow'; 
        alert("Please enter your name");
    	return false;
	} 
	if (fld.value.length < 1 || fld.value.length > 100) {
        fld.style.background = 'Yellow'; 
        alert('The name should be no more than 100 characters.');
    	return false;
	}
	     
    var tfld = trim(fld2.value);// value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
    
    if (fld2.value == "") {
        fld2.style.background = 'Yellow';
        alert("You didn't enter an email address.\n");
		return false;
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld2.style.background = 'Yellow';
        alert("Please enter a valid email address.\n");
		return false;
    } else if (fld2.value.match(illegalChars)) {
        fld2.style.background = 'Yellow';
        alert("The email address contains illegal characters.\n");
		return false;
    } else {
        fld2.style.background = 'White';
    }    
	
    
}
function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
} 
