<!--
function validField(fieldName,fieldDesc,testBlank,typeValid,extraChars,minChars,maxChars) {
// ... test for blank field 
   if (testBlank == "noblank") {
      if (fieldName.value == "") {
         errorFound=true
         errorMessage=errorMessage+"\n* "+fieldDesc+" can't be blank"
         if ( firstError ) {
            firstError=false
            errorField=fieldName
         }
      }
   }
// ... test each character for numeric or extra list of chars
   if (typeValid=="numeric") {
      invalidChar=false
      testString=fieldName.value      
      for (i=0; i<testString.length; i++) {
         testChar=testString.charAt(i)         
         if (!(testChar>="0" && testChar<="9")) {            
            if (extraChars.indexOf(testChar,0)==-1) {
               invalidChar=true
            }        
         }
      }
      if(invalidChar) {            
         errorFound=true
         errorMessage=errorMessage+"\n* "+fieldDesc+" must comprise 0-9"
         addExtras(extraChars)
         if (firstError) {
            firstError=false
            errorField=fieldName
         }
      }
   }
// ... test each character for alpha or extra list of chars
   if (typeValid=="alpha") {
      invalidChar=false
      testString=fieldName.value      
      for (i=0; i<testString.length; i++) {
         testChar=testString.charAt(i)         
         if (!(testChar>="a" && testChar<="z") && !(testChar>="A" && testChar<="Z")) {            
            if (extraChars.indexOf(testChar,0)==-1) {
               invalidChar=true
            }        
         }
      }
      if(invalidChar) {            
         errorFound=true
         errorMessage=errorMessage+"\n* "+fieldDesc+" must comprise a-z"
         addExtras(extraChars)
         if (firstError) {
            firstError=false
            errorField=fieldName
         }
      }
   }
// ... test each character for alphanumeric or extra list of chars
   if (typeValid=="alphanumeric") {
      invalidChar=false
      testString=fieldName.value      
      for (i=0; i<testString.length; i++) {
         testChar=testString.charAt(i)         
         if (!(testChar>="a" && testChar<="z") && !(testChar>="A" && testChar<="Z") && !(testChar>="0" && testChar<="9")) {            
            if (extraChars.indexOf(testChar,0)==-1) {
               invalidChar=true
            }        
         }
      }
      if(invalidChar) {            
         errorFound=true
         errorMessage=errorMessage+"\n* "+fieldDesc+" must comprise a-z or 0-9"
         addExtras(extraChars)
         if (firstError) {
            firstError=false
            errorField=fieldName
         }
      }
   }  
// ... test each character for email
	if (typeValid=="email") {
      invalidChar=false
      testString=fieldName.value
	  var invalidPatterns = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; 
	  var validPatterns = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; 
      	
		if (window.RegExp) { 
	 
		  if (!invalidPatterns.test(testString) && validPatterns.test(testString)) { 
		  } 
		  else {
		   invalidChar = true;
		  }
		  if(testString.indexOf("@") < 0){
			   invalidChar = true; 
		  } 
		 
		}
		  if(invalidChar) {            
			 errorFound=true
			 errorMessage=errorMessage+"\n* "+fieldDesc+" must be valid"
			 addExtras(extraChars)
			 if (firstError) {
				firstError=false
				errorField=fieldName
			 }
		  }
	   
	}
// ... test for exclusion list of chars
   if(typeValid=="banchars") {
      for (i=0; i<extraChars.length; i++) {
         badChar=extraChars.charAt(i)
         if (fieldName.value.indexOf(badChar,0) > -1) {
            errorFound=true
            if (badChar=="\'"||badChar=="\"") {
               errorMessage=errorMessage+"\n* "+fieldDesc+ " can not contain the character '"+badChar+"'"
            }
            else {
               errorMessage=errorMessage+"\n* "+fieldDesc+ " can not contain the character '"+badChar+"'"
            }
            if ( firstError ) {
               firstError=false
               errorField=fieldName
            }         
         }
      }
   }
// ... test for checked box
   if (typeValid=="checked") {      
      if(!fieldName.checked) {            
         errorFound=true
         errorMessage=errorMessage+"\n* "+fieldDesc
         addExtras(extraChars)
         if (firstError) {
            firstError=false
            errorField=fieldName
         }
      }
   } 
// ... test for minimum character length if something entered 
   if (minChars>=1) {
      testString=fieldName.value
      if (testString.length>0 && testString.length<minChars) {
         errorFound=true
         errorMessage=errorMessage+"\n* "+fieldDesc+" must be at least "+minChars+" char"
         if (minChars>1) {
            errorMessage=errorMessage+"s"
         }
         if (firstError) {
            firstError=false
            errorField=fieldName
         }
      }
   }
// ... test for maximum character length
   if (maxChars>=1) {
      testString=fieldName.value
      if (testString.length>maxChars) {
         errorFound=true
         errorMessage=errorMessage+"\n* "+fieldDesc+" must be no more than "+maxChars+" char"
         if (maxChars>1) {
            errorMessage=errorMessage+"s"
         }
         if (firstError) {
            firstError=false
            errorField=fieldName
         }
      }      
   }
}
// ... routine to add display of extra chars to error message
function addExtras(extraChars) {
   for (i=0; i<extraChars.length; i++) {
      goodChar=extraChars.charAt(i)
      errorMessage=errorMessage+" or "
      if (goodChar==" ") {
         errorMessage=errorMessage+"'space'"
      }
      else {
         errorMessage=errorMessage+"'"+goodChar+"'"
      }
   }
}
// ... special routine to check credit card expiry date
function validExpdate(expMonth,expYear,cardNum,errorText) {
   now=new Date
   currentMonth=now.getMonth()+1
   currentYear=now.getFullYear()-2000   
   currentDate=currentMonth+100*currentYear
   exMonth=parseInt(expMonth.value,10)
   exYear=parseInt(expYear.value,10)
   exDate=exMonth+100*exYear
   if (exDate<currentDate) {
      errorFound=true
      errorMessage=errorMessage+"\n"+errorText
      if (firstError) {
            firstError=false
            errorField=cardNum
      }
   }
}
// ... routine to validate any date, particularly that day of month is valid, leap year every 4 or 400, not 100
function validDate(day,month,year) {
  daysMonth=new Array (31,28,31,30,31,30,31,31,30,31,30,31)
  if( (year%4==0) && ( (year%400==0) || (year%100!=0) ) ) {
     daysMonth[1]=29
  }  
  if((month<13)&&(day<=daysMonth[month-1])) {  
     return true
  } 
  else {
     return false
  }
}   
//-->
