
// non-empty textbox
function isEmpty(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter a comment.\n"
  }
return error;	  
}

// name - 4-10 chars, uc, lc, and underscore only.
function checkName (strng) {
var error = "";
    var illegalChars = /\W\ /; // allow letters, numbers, and underscores
    if (strng == 0) {
   error = "Please enter your name.\n";
	}
	else if (strng.length < 2) {
       error = "The name is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The name contains illegal characters.\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;
}

// tel number - check for 10 digits and strip out non-numeric characters
function checkTel (strng) {
var error = "";
var stripped = strng.replace(/[\(\)\.\-\ \+]/g, "");
var illegalChars = strng.replace(/[\(\)\.\-\ \0-9\+]/g, "");
	if (strng == "") {
   	error = "Please enter your tel number.\n";
	}
	else if (illegalChars.length != 0) {
       	error = "The cell number contains illegal characters.\n";
	}	
	else if (stripped.length < 10) {
		error = "The tel number is the wrong length. Please make sure you include the area code.\n";
	}
return error;
}


// non-empty codebox
function codeBox(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter the security code.\n"
  }
return error;	  
}

/*
// surnname - 4-10 chars, uc, lc, and underscore only.
function checkSurname (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a surname.\n";
}
    var illegalChars = /\W\ /; // allow letters, numbers, and underscores
    if ((strng.length < 3)) {
       error = "The surname is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The surnname contains illegal characters.\n";
    } 
return error;
} 

*/
 


