// non-empty textbox
function checkComment(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter a comment.\n"
  }
return error;	  
}

// non-empty textbox
function checkBrief(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter a brief job description.\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.length < 2)) {
       error = "Your name is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "Your name contains illegal characters.\n";
    } 
	
if (strng == "") {
   error = "Please enter your name.\n";
}	
return error;
}


// Company - 4-10 chars, uc, lc, and underscore only. **************************************************************************

function checkCompany (strng) {
var error = "";

    var illegalChars = /\W\ /; // allow letters, numbers, and underscores
    if ((strng.length < 2)) {
       error = "Your company name is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "Your company name contains illegal characters.\n";
    } 
	
if (strng == "") {
   error = "Please enter your company name.\n";
}	
return error;
}   
    
    
// tel number - strip out delimiters and check for 10 digits ***********************************************************

function checkTel (strng) {
var error = "";

var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "The telephone number contains illegal characters.\n";
    }
	
    if ((stripped.length < 7)) {
	error = "The telephone number is the wrong length. Make sure you included an area code.\n";
    } 	
	

if (strng == "") {
   error = "Please enter your telephone number.\n";
}
	
return error;
}
// non-empty codebox
function codeBox(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter the security code.\n"
  }
return error;	  
}

// email *****************************************************************************************************

function checkEmail (strng) {
var error="";

    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";
       }
    }

if (strng == "") {
   error = "Please enter your email address.\n";
}
	
return error;    
}

// valid title
function checkJType(choice) {
var error = "";
    if (choice == 0) {
    error = "Please select the type of job.\n";
    }    
return error;
}

// valid title
function checkJBudget(choice) {
var error = "";
    if (choice == 0) {
    error = "Please select your budget.\n";
    }    
return error;
}
