

<!-- //BEGIN FORM FIELD VALIDATION 
var charexp = /./;                                //CHECK FOR ANY CHARACTER EXCEPT NEW LINE 
var letterexp = /^[a-z]/i;                         //CHECK FOR ANY CHARACTER THAT'S A TO Z i DENOTES IT'S CASE SENSITIVE 
//var numberexp = /^\d*\.?\d*[1-9]+\d*)|(^[1-9]+\d*\.\d*/; //CHECK FOR NUMERIC CHARACTERS ONLY
var zipexp = /^\d{5}$/;                                //CHECK FOR FIVE DIGIT NUMBER 
var emailexp = /^[a-z_0-9\.]+@[a-z_0-9\.]/i;        //CHECK FOR valid email address 
var dateexp =  /^([01][012]|0[1-9])\/([0-2][0-9]|[3][0-1])\/([0-9][0-9][0-9][0-9])$/; //CHECK FOR mm/dd/yyyy date 

///^(?:(?:0?[13578]|1[02])|(?:0?[469]|11)(?!\/31)|(?:0?2)(?:(?!\/3[01]|\/29\/(?:(?:0[^48]|[13579][^26]|[2468][^048])00|(?:\d{2}(?:0[^48]|[13579][^26]|[2468][^048]))))))\/(?:0?[1-9]|[12][0-9]|3[01])\/\d{4}$/;
///^((((0[13578])|([13578])|(1[02]))[\/](([1-9])|([0-2][0-9])|(3[01])))|(((0[469])|([469])|(11))[\/](([1-9])|([0-2][0-9])|(30)))|((2|02)[\/](([1-9])|([0-2][0-9]))))[\/]\d{4}$|^\d{4}$/;
///^((((0[13578])|(1[02]))[\/]?(([0-2][0-9])|(3[01])))|(((0[469])|(11))[\/]?(([0-2][0-9])|(30)))|(02[\/]?[0-2][0-9]))[\/]?\d{4}$/;

       


function isFormatValid(pattern, str) 
{ 
        return pattern.test(str); 
} 

function hasLetter(str) 
{ 
        return letterexp.test(str); 
} 

function hasNumber(str) 
{ 
        return numberexp.test(str); 
} 

function hasChar(str) 
{ 
        return charexp.test(str); 
} 

function validateForm(frmName) 
{ 
	var thisform = document.getElementById(frmName);
	var message = "Please correct the following fields:\n";
	var isValid = true;
	
	for(var i=0; i<countValidateFields; i++)
	{
		
		var fieldname = arrValidateFields[i][0];
		var valtype = arrValidateFields[i][1];
		var displayname = arrValidateFields[i][2];
		var divname = arrValidateFields[i][3];
		var doValidation = true;
		  
		if  ( divname != null )
		{
			var thisdiv = document.getElementById(divname);
			if ( thisdiv.style.display == "none")
			{
				doValidation = false;
			}
		}
		
		
		
		if (doValidation)
		{
			
			if (valtype == "required")
			{
				if (!hasChar(thisform[fieldname].value)) 
						{ 
						message += displayname + " is required \n"; 
						isValid = false;                
						} 		
			}
			
			
			if (valtype == "email")
			{
				if (hasChar(thisform[fieldname].value))
					{
						if (!isFormatValid(emailexp,thisform[fieldname].value)) 
								{ 
								message += displayname + " is not a valid email address (e.g., jsmith@abc.net) \n"; 
								isValid = false;                
								} 		
					}
				
			}
			
			if (valtype == "zip")
			{
				if (hasChar(thisform[fieldname].value))
					{
						if (!isFormatValid(zipexp,thisform[fieldname].value)) 
								{ 
								message += displayname + " is not a valid US Zip Code \n"; 
								isValid = false;                
								} 		
					}
				
			}
			
			if (valtype == "date")
			{
				if (hasChar(thisform[fieldname].value))
					{
						if (!isFormatValid(dateexp,thisform[fieldname].value)) 
								{ 
								message += displayname + " is not formatted mm/dd/yyyy \n"; 
								isValid = false;                
								} 		
					}
				
			}
			
			if (valtype == "alpha")
			{
				if (hasChar(thisform[fieldname].value))
					{
						if (!hasLetter(thisform[fieldname].value)) 
								{ 
								message += displayname + " is not a valid entry - use letters only \n"; 
								isValid = false;                
								} 		
					}
				
			}
			/*
			if (valtype == "numeric")
			{
				if (hasChar(thisform[fieldname].value))
					{
						if (!hasNumber(thisform[fieldname].value)) 
								{ 
								message += displayname + " is not a valid entry - use numbers only \n"; 
								isValid = false;                
								} 		
					}
				
			}
			*/
			
		}
	}

	if (isValid)
	{
		return "";
		//thisform.submit();
	}
	else
	{
		return message;
		//alert(message);
	}
} 
