// JavaScript Document

function validate()
//Validation function for Customer Inquiry Form


{
// Customer's Name ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//  If Customer's Name Required - testing for input
			if(document.formup.adname.value=="")
					{ alert("Please provide Customer's Name.");
					document.formup.adname.focus();
					return false; }

//  If Field Populated, subTest for valid characters:  alpha and dashes by matching illegal characters  
			if(!(document.formup.adname.value=="")) 
				{
					
					var illegalChars= /[\@\(\)\<\>\,\;\:\.\\\/\"\[\][0-9}]/;  
				 
					if (document.formup.adname.value.match(illegalChars))
					{ alert("Customer's Name field contains illegal characters. \n\n Please use only alpha characters, apostrophess and dashes");      
						document.formup.adname.focus();
						return false; }
				}	
				
// Company ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//  If Company Required - testing for input
				if(document.formup.company.value=="")
						{ alert("Please provide your Company Name.");
						document.formup.company.focus();
						return false; }

//  If Field Populated, subTest for valid characters:  alpha and dashes by matching illegal characters  
			if(!(document.formup.company.value=="")) 
				{
					
					var illegalChars= /[\@\(\)\<\>\;\:\\\/\"\[\][}]/;  
				 
					if (document.formup.company.value.match(illegalChars))
					{ alert("Company Name contains illegal characters. \n\n Please use only alpha characters, apostrophess and dashes");      
						document.formup.company.focus();
						return false; }
				}	
				

// Address ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	
	//  If Address Required - testing for input
			//	if(document.formup.addr.value=="")
			//			{ alert("Please provide your Address.");
			//			document.formup.addr.focus();
			//			return false; }

	
	
	//  If Field Populated, subTest for valid characters:  alpha and dashes by matching illegal characters  
	//		if(!(document.formup.addr.value=="")) 
	//			{
					
	//				var illegalChars= /[\@\(\)\<\>\,\;\:\.\\\/\"\[\][}]/;  
				 
	//				if (document.formup.addr.value.match(illegalChars))
	//				{ alert("Address contains illegal characters. \n\n Please use only alpha-numeric characters, apostrophes and dashes");      
	//					document.formup.addr.focus();
	//					return false; }
	//			}	
	
	
// Address Continuation ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

				
	//  If Field Populated, subTest for valid characters:  alpha and dashes by matching illegal characters  
	//		if(!(document.formup.addr2.value=="")) 
	//			{
					
	//				var illegalChars= /[\@\(\)\<\>\,\;\:\.\\\/\"\[\][}]/;  
				 
	//				if (document.formup.addr2.value.match(illegalChars))
	//				{ alert("Address con't contains illegal characters. \n\n Please use only alpha-numeric characters, apostrophes and dashes");      
	//					document.formup.addr2.focus();
	//					return false; }
	//			}	

				
// City ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//  If City Required - testing for input
//			if(document.formup.city.value=="")
//					{ alert("Please provide your City.");
//					document.formup.city.focus();
//					return false; }
					
//  If Field Populated, subTest for valid characters:  alpha and dashes by matching illegal characters  
//			if(!(document.formup.city.value=="")) 
	//			{
					
	//				var illegalChars= /[\@\(\)\<\>\,\;\:\.\\\/\"\[\][0-9}]/;  
				 
	//				if (document.formup.city.value.match(illegalChars))
	//				{ alert("City contains illegal characters. \n\n Please use only alpha characters, apostrophe and dashes");      
	//				document.formup.city.focus();
						return false; }
	//			}	
				
// State ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++					

//  If State Required - testing for input
	//		if(document.formup.state.value=="")
	//				{ alert("Please select a State.");
	//				document.formup.state.focus();
	//				return false; }
			

// Zip Code ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++								

// If Zip Code Required - testing for input, length and numerical values
//			if(document.formup.zipcode.value=="")
//					{ alert("Please provide your Zip Code.");
//					document.formup.zipcode.focus();
//					return false; }

	//  If Field Populated, subTest for for illegal characters (alpha-numeric valid for international postal codes) & correct length 
//			if(!(document.formup.zipcode.value==""))
//					{
					// Test for correct length of field  
//							theField = document.formup.zipcode.value;
//							theLength = theField.length;
		
//							for (i=0; i<= theLength-1; i++);
					
							//if(!(theLength == 5))
									//{alert("The Zip Code entered is not a valid length. A minimum of 5 digits are required.");
									//document.formup.zipcode.focus();
									//return false; }
									
//						 	var illegalChars= /[\(\)\<\>\,\;\:\.\\\/\"\[\]\@}]/;  
 
//							if (document.formup.zipcode.value.match(illegalChars))
//								{ alert("Zip Code contains illegal characters. \n\n Please use only alpha-numeric characters and dashes");  
//									document.formup.zipcode.focus();
//									return false; }
//						}
							
// Phone Number ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++					
//**********   Valdiate phone number provided - required
			if(document.formup.phone.value=="")
						{ alert("Please provide phone number to contact you if we have questions on your submission.")
						document.formup.phone.focus()
						return false }
			
			if(!(document.formup.phone.value=="")) 
						{
							
							var illegalChars= /[\@\<\>\\\/\[\][}]/;  
						 
							if (document.formup.phone.value.match(illegalChars))
							{ alert("Phone field contains illegal characters. \n\n Please enter only numeric characters.");      
								document.formup.phone.focus();
								return false; }
						}				
						
					//{			
			//check that phone number contains all digits and is a valid length
					//theField = document.formup.phone.value
					//theLength = theField.length
					
					//for (i=0; i<= theLength-1; i++)
					
					
							//if(theField.charAt(i) < "0" || theField.charAt(i) > "9")
									//{ alert("Phone must contain only numeric characters and dashes. \n\n Please use this format 111-111-1111.")
									//document.formup.phone.focus()
									//return false }
			
					

			//	if(!(theLength == 14))
						//	{ alert("The Telephone Number you entered is not a valid length.  Make sure you include both area code and number.")
							//document.formup.phone.focus()
							//return false }
				//	}
					

// Email Address ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++			

//  Email Address Required - testing for input
				if(document.formup.email.value=="")
				{ alert("To process the submission, please provide your Email Address.")
				document.formup.email.focus()
				return false }
				
				// Test for valid format
				var emailFilter=/^.+@.+\..{2,3}$/;
				
				if(!(emailFilter.test(document.formup.email.value)))
						{ alert("Please provide a valid Email Address format:  xxxx@yyyy.zzz.");
						document.formup.email.focus(); 
						return false; }

//**********  If Comment Field Populated, subTest for valid characters:  alpha and dashes by matching illegal characters  
					if(!(document.formup.comments.value=="")) 
						{
							
							var illegalChars= /[\@\<\>\\\/\[\][}]/;  
						 
							if (document.formup.comments.value.match(illegalChars))
							{ alert("Comments Box contains illegal characters. \n\n Please use only alpha characters, apostrophes and dashes. \n\nPlease do not enter any email address in this text box.");      
								document.formup.comments.focus();
								return false; }
						}	



//  If Field Populated, subTest for valid characters:  alpha and dashes by matching illegal characters  
			if(!(document.formup.FILE1.value=="")) 
				{
					
					var illegalChars= /[\@\][}]/;  
				 
					if (document.formup.FILE1.value.match(illegalChars))
					{ alert("File Upload Field contains an illegal character. \n\n An @ symbol was entered.");      
						document.formup.FILE1.focus();
						return false; }
				}	
					


//Return confirmation to user that data entered correctly and now being submitted for processing
alert("Your form is being submitted and may take a few seconds. \n\n Please do not Click on SUBMIT again. \n\n Click \"OK\" and await the form to upload your Ad Image. \n\n Thank you")

}

