// name - 4-10 chars, uc, lc, and underscore only.
function checkName (strng) {
var error = "";
    var illegalChars = /\W\ /; // allow letters, numbers, and underscores
    if ((strng.length < 2)) {
       error = "The name is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The name contains illegal characters.\n";
    } 
	
if (strng == "") {
   error = "Please enter your name.\n";
}
return error;
}
   
// email
function checkEmail (strng) {
var error="";

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "The email address is invalid.\n";
    }
    else {
	//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
if (strng == "") {
   error = "Please enter your email address.\n";
}	
return error;
}

// drop down selected
function checkContact(choice) {
var error = "";
    if (choice == 0) {
    error = "Please select a contact method.\n";
    }    
return error;
}  

// cell number - check for 10 digits and strip out non-numeric characters
function checkCell (strng) {
var error = "";
var stripped = strng.replace(/[\(\)\.\-\ \+]/g, "");
var illegalChars = strng.replace(/[\(\)\.\-\ \0-9\+]/g, "");
	if (strng == "") {
   	error = "Please enter your cell number.\n";
	}
	else if (illegalChars.length != 0) {
       	error = "The cell number contains illegal characters.\n";
	}	
	else if (stripped.length < 10) {
		error = "The cell number is the wrong length.\n";
	}
return error;
}

// tel number - check for 10 digits
function checkTel (strng) {
var error = "";
	if (strng.length == 0) {
   	error = "Please enter your tel number.\n";
	}
	else if (strng.length != 10) {
       error = "The tel number is the wrong length.\n";
    }
return error;
}

// text box in not empty
function checkInv (strng) {
var error = "";
    if (strng == "") {
    error = "Please enter an invoice code.\n";
    }    
return error;
} 

// non-empty commentbox
function checkCom(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter a comment.\n"
  }
return error;	  
}

// non-empty codebox
function codeBox(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter the security code.\n"
  }
return error;	  
}


/*// drop down selected
function checkProduct(strng) {
var error = "";
    if (strng == "") {
    error = "Please enter the type of product.\n";
    }    
return error;
}  


// drop down selected
function checkColour(choice) {
var error = "";
    if (choice == 0) {
    error = "Please select a colour.\n";
    }    
return error;
}  

// drop down selected
function checkSize(choice) {
var error = "";
    if (choice == 0) {
    error = "Please select the size.\n";
    }    
return error;
}*/  