function checkRequestBy (strng) {
var error = "";
 var filter = /^[\w\.\-\&\s]+$/; // allow letters, numbers,underscores, whitespace character, periods,dash, and amp.
if (!(strng == "")) {
 if (!filter.test(strng)) {
    error = "The \"Request By\" Name contains unprocessable characters. Please omit any special characters.\n";
    } }
return error;
}  

function checkShipTo (strng) {
var error = "";
 var filter = /^[\w\.\-\&\s]+$/; // allow letters, numbers,underscores, whitespace character, periods,dash, and amp.
if (strng == "") {
   error = "Please enter a Ship To name.\n";
}

 else if ((strng.length < 2) || (strng.length > 30)){
       error = "Please enter a valid Ship To name.\n";
    }
 else if (!filter.test(strng)) {
    error = "The Ship To name contains unprocessable characters. Please omit any special characters.\n";
    } 
return error;
}  


function checkAttention (strng) {
var error = "";
 var filter = /^[\w\.\-\&\s]+$/; // allow letters, numbers,underscores, whitespace character, periods,dash, and amp.
if (!(strng == "")) {
 if (!filter.test(strng)) {
    error = "The \"Attention\" Name contains unprocessable characters. Please omit any special characters.\n";
    } }
return error;
}  



function checkAddress1 (strng) {
var error = "";
 var filter = /^[\w\.\-\&\,\:\s]+$/;
if (strng == "") {
   error = "Please enter an Address.\n";
}
else if (!filter.test(strng)) {
    error = "The address contains unprocessable characters. Please omit any special characters.\n";
    } 
return error;
}  


function checkAddress2 (strng) {
var error = "";
if (!(strng == "")) {
    var filter = /^[\w\.\-\&\,\:\s]+$/; 
   if (!filter.test(strng)) {
    error = "Not able process the second line address. Please omit any special characters.\n";
    } 
    }
return error;
} 


function checkCity (strng) {
var error = "";
 var filter = /^[\w\.\-\&\,\s]+$/; 
if (strng == "") {
   error = "Please enter a City name.\n";
}
else if (!filter.test(strng)) {
    error = "Not able process that city name. Please omit any special characters.\n";
    } 
return error;
}  

function checkStateAbbr (strng) {
var error = "";
 var filter = /^[a-zA-Z]{2}$/; 
if (strng == "") {
   error = "Please enter your State Abbr.\n";
}
else if (!filter.test(strng)) {
    error = "Not able process that state abbreviation.\n";
    } 
return error;
}  

function checkZip (strng) {
var error = "";
var zipFilter=/^\d{5}$/;
if (strng == "") {
   error = "Please enter a Zip Code.\n";
}
/* else if (!(zipFilter.test(strng))) { 
     error = "Please enter a valid Zipcode.\n";
    }
*/
 return error;
}

function checkZipExt (strng) {
var error = "";
var zipFilter=/^\d{4}$/;
if (!(strng == "")) {
 if (!(zipFilter.test(strng))) { 
       error = "Please enter a valid Zipcode Extension.\n";
    }}
 return error;
}


// check area code is 3 digits
function checkAreaCode (strng) {
var error = "";
var filter =/[0-9]{3}/;
if (strng == "") {
   error = "Please include your Area Code.\n";
}
else if (!(filter.test(strng))) { 
       error = "Please enter a valid Area Code.\n";
    }
 return error;
}


function checkPhone (strng) {
var error = "";
var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
if (strng == "") {
   error = "Please enter a Phone number.\n";
}


 else if (isNaN(parseInt(stripped))) {
       error = "The Phone number contains illegal characters.";
  
    }
 else if (!(stripped.length == 7)) {
error = "Please recheck the Phone number entered. It doesn't match a typical number.\n";
  } 
return error;
}



// check area code is 3 digits
function checkF_AreaCode (strng) {
var error = "";
var filter =/[0-9]{3}/;
if (!(strng == "")) {
 if (!(filter.test(strng))) { 
       error = "Please enter a valid Area Code.\n";
    }}
return error;
}


function checkFax (strng) {
var error = "";
var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
if (!(strng == ""))  {
 if (isNaN(parseInt(stripped))) {
       error = "The Phone number contains illegal characters.";
  
    }
 else if (!(stripped.length == 7)) {
error = "Please recheck the Phone number entered. It doesn't match a typical number.\n";
  } }
return error;
}


function checkEmail (strng) {
var error="";
 var emailFilter=/^.+@.+\..{2,3}$/;
var illegalChars= "/[\(\)\<\>\,\;\:\\\"\[\]]/";
if (strng == "") {
   error = "Please enter an Email address.\n";
}

   
 else if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid Email address.\n";
    }
    else if (strng.match(illegalChars)){
//test email for illegal characters
         error = "The Email address contains unprocessable  characters.\n";
       }

return error;    
}




function checkSidemark (strng) {
var error = "";
 var filter = /^[\w\.\-\&\s]+$/; // allow letters, numbers,underscores, whitespace character, periods,dash, and amp.
if (!(strng == "")) {
 if (!filter.test(strng)) {
    error = "Sidemark contains unprocessable characters. Please omit any special characters.\n";
    } }
return error;
}  



function checkPattern1_number (strng) {
var error = "";
 var filter = /^[\w\.\-\&\s]+$/; // allow letters, numbers,underscores, whitespace character, periods,dash, and amp.
if (strng == "") {
   error = "Please enter a Pattern Number for row 1.\n";
}

 else if ((strng.length < 2) || (strng.length > 30)){
       error = "Please enter a valid Pattern Number in row 1.\n";
    }
 else if (!filter.test(strng)) {
    error = "The Pattern Number in row 1 contains unprocessable characters. Please omit any special characters.\n";
    } 
return error;
}  

function checkPattern1_name (strng) {
var error = "";
 var filter = /^[\w\.\-\&\s]+$/; // allow letters, numbers,underscores, whitespace character, periods,dash, and amp.
if (strng == "") {
   error = "Please enter a Pattern Name for row 1.\n";
}

 else if ((strng.length < 2) || (strng.length > 30)){
       error = "Please enter a valid Pattern Name in row 1.\n";
    }
 else if (!filter.test(strng)) {
    error = "The Pattern Name in row 1 contains unprocessable characters. Please omit any special characters.\n";
    } 
return error;
}  

function checkPattern1_quantity (strng) {
var error = "";
var filter= /\d+/;
if (strng == "") {
   error = "Please enter a Quantity for row 1.\n";
}
 
else if (strng.length > 3) {
       error = "The Quantity in row 1 may not be an unreasonable amount.\n";
    }
else if (!(filter.test(strng))) { 
          error = "The Quantity in row 1 may only contain a number.\n";
    }

return error;	  
}


function checkPattern2_number (strng) {
var error = "";
 var filter = /^[\w\.\-\&\s]+$/; // allow letters, numbers,underscores, whitespace character, periods,dash, and amp.
if (!(strng == "")) {
 if ((strng.length < 2) || (strng.length > 30)){
       error = "Please enter a valid Pattern Number in row 2.\n";
    }
 else if (!filter.test(strng)) {
    error = "The Pattern Number in row 2 contains unprocessable characters. Please omit any special characters.\n";
    } }
return error;
}  

function checkPattern2_name (strng) {
var error = "";
 var filter = /^[\w\.\-\&\s]+$/; // allow letters, numbers,underscores, whitespace character, periods,dash, and amp.
if (!(strng == "")) {
if ((strng.length < 2) || (strng.length > 30)){
       error = "Please enter a valid Pattern Name in row 2.\n";
    }
 else if (!filter.test(strng)) {
    error = "The Pattern Name in row 2 contains unprocessable characters. Please omit any special characters.\n";
    }} 
return error;
}  

function checkPattern2_quantity (strng) {
var error = "";
var filter= /\d+/;
if (!(strng == "")) {
 if (strng.length > 3) {
       error = "The Quantity in row 2 may not be an unreasonable amount.\n";
    }
else if (!(filter.test(strng))) { 
          error = "The Quantity in row 2 may only contain a number.\n";
    }}

return error;	  
}



function checkPattern3_number (strng) {
var error = "";
 var filter = /^[\w\.\-\&\s]+$/; // allow letters, numbers,underscores, whitespace character, periods,dash, and amp.
if (!(strng == "")) {
 if ((strng.length < 2) || (strng.length > 30)){
       error = "Please enter a valid Pattern Number in row 3.\n";
    }
 else if (!filter.test(strng)) {
    error = "The Pattern Number in row 3 contains unprocessable characters. Please omit any special characters.\n";
    } }
return error;
}  

function checkPattern3_name (strng) {
var error = "";
 var filter = /^[\w\.\-\&\s]+$/; // allow letters, numbers,underscores, whitespace character, periods,dash, and amp.
if (!(strng == "")) {
if ((strng.length < 2) || (strng.length > 30)){
       error = "Please enter a valid Pattern Name in row 3.\n";
    }
 else if (!filter.test(strng)) {
    error = "The Pattern Name in row 3 contains unprocessable characters. Please omit any special characters.\n";
    }} 
return error;
}  

function checkPattern3_quantity (strng) {
var error = "";
var filter= /\d+/;
if (!(strng == "")) {
 if (strng.length > 3) {
       error = "The Quantity in row 3 may not be an unreasonable amount.\n";
    }
else if (!(filter.test(strng))) { 
          error = "The Quantity in row 3 may only contain a number.\n";
    }}

return error;	  
}

function checkPattern4_number (strng) {
var error = "";
 var filter = /^[\w\.\-\&\s]+$/; // allow letters, numbers,underscores, whitespace character, periods,dash, and amp.
if (!(strng == "")) {
 if ((strng.length < 2) || (strng.length > 30)){
       error = "Please enter a valid Pattern Number in row 4.\n";
    }
 else if (!filter.test(strng)) {
    error = "The Pattern Number in row 4 contains unprocessable characters. Please omit any special characters.\n";
    } }
return error;
}  

function checkPattern4_name (strng) {
var error = "";
 var filter = /^[\w\.\-\&\s]+$/; // allow letters, numbers,underscores, whitespace character, periods,dash, and amp.
if (!(strng == "")) {
if ((strng.length < 2) || (strng.length > 30)){
       error = "Please enter a valid Pattern Name in row 4.\n";
    }
 else if (!filter.test(strng)) {
    error = "The Pattern Name in row 4 contains unprocessable characters. Please omit any special characters.\n";
    }} 
return error;
}  

function checkPattern4_quantity (strng) {
var error = "";
var filter= /\d+/;
if (!(strng == "")) {
 if (strng.length > 3) {
       error = "The Quantity in row 4 may not be an unreasonable amount.\n";
    }
else if (!(filter.test(strng))) { 
          error = "The Quantity in row 4 may only contain a number.\n";
    }}

return error;	  
}

function checkPattern5_number (strng) {
var error = "";
 var filter = /^[\w\.\-\&\s]+$/; // allow letters, numbers,underscores, whitespace character, periods,dash, and amp.
if (!(strng == "")) {
 if ((strng.length < 2) || (strng.length > 30)){
       error = "Please enter a valid Pattern Number in row 5.\n";
    }
 else if (!filter.test(strng)) {
    error = "The Pattern Number in row 5 contains unprocessable characters. Please omit any special characters.\n";
    } }
return error;
}  

function checkPattern5_name (strng) {
var error = "";
 var filter = /^[\w\.\-\&\s]+$/; // allow letters, numbers,underscores, whitespace character, periods,dash, and amp.
if (!(strng == "")) {
if ((strng.length < 2) || (strng.length > 30)){
       error = "Please enter a valid Pattern Name in row 5.\n";
    }
 else if (!filter.test(strng)) {
    error = "The Pattern Name in row 5 contains unprocessable characters. Please omit any special characters.\n";
    }} 
return error;
}  

function checkPattern5_quantity (strng) {
var error = "";
var filter= /\d+/;
if (!(strng == "")) {
 if (strng.length > 3) {
       error = "The Quantity in row 5 may not be an unreasonable amount.\n";
    }
else if (!(filter.test(strng))) { 
          error = "The Quantity in row 5 may only contain a number.\n";
    }}

return error;	  
}

function checkNotes(strng) {
var error = "";
var illegalChars= /[\<\>\[\]\%\^\*\=]/;
if (illegalChars.test(strng)) { 
       error = "Not able process the note. Please try again without any special characters. We appreciate your feed back.\n";
    }
 return error;
}


function checkWholeForm(theForm) {
    var why = "";
  	why += checkRequestBy(theForm.RequestBy.value);    
    why += checkShipTo(theForm.ShipTo.value);
	why += checkAttention(theForm.Attention.value);
  	why += checkAddress1(theForm.Address1.value);
  	why += checkAddress2(theForm.Address2.value);
  	why += checkCity(theForm.City.value);
	why += checkStateAbbr(theForm.StateAbbr.value);
  	why += checkZip(theForm.Zipcode.value);
  	why += checkZipExt(theForm.ZipExt.value);
   	why += checkAreaCode(theForm.AreaCode.value);
   	why += checkPhone(theForm.Phone.value);
   	why += checkF_AreaCode(theForm.F_AreaCode.value);
   	why += checkFax(theForm.Fax.value);
   	why += checkEmail(theForm.Email.value);
  	why += checkSidemark(theForm.Sidemark.value);
 	why += checkPattern1_number(theForm.pattern1_number.value);
 	why += checkPattern1_name(theForm.pattern1_name.value);
	why += checkPattern1_quantity(theForm.pattern1_quantity.value);
    why += checkPattern2_number(theForm.pattern2_number.value);
 	why += checkPattern2_name(theForm.pattern2_name.value);
	why += checkPattern2_quantity(theForm.pattern2_quantity.value);
  	why += checkPattern3_number(theForm.pattern3_number.value);
 	why += checkPattern3_name(theForm.pattern3_name.value);
	why += checkPattern3_quantity(theForm.pattern3_quantity.value);
  	why += checkPattern4_number(theForm.pattern4_number.value);
 	why += checkPattern4_name(theForm.pattern4_name.value);
	why += checkPattern4_quantity(theForm.pattern4_quantity.value);
	why += checkPattern5_number(theForm.pattern5_number.value);
 	why += checkPattern5_name(theForm.pattern5_name.value);
	why += checkPattern5_quantity(theForm.pattern5_quantity.value);

  why += checkNotes(theForm.Notes.value);
   
   if (why != "") {
       alert(why);
       return false;
    }
return true;
}