 
	  function formValidation(thisform)
{ 
	with (thisform)
	{ 
			if(fname.value=="Name")fname.value="";		
			if (emptyvalidation(fname,"Woops! You forgot to fill your Name")==false) 
			{
				fname.select();
				fname.focus();
				return false;
			}
			if(address.value=="Address")address.value="";
			if (emptyvalidation(address,"Woops! You forgot to fill your Address")==false) 
			{
				address.select();
				address.focus();
				return false;
			}
			if(email2.value=="Email")email2.value="";		
			if (emptyvalidation(email2,"Woops! You forgot to fill your Email")==false) 
			{
				email2.select();
				email2.focus();
				return false;
			}
			
				if(emailvalidation(email2)==false)
				{
					alert("Woops! You have entered an invalid Email Address");
					email2.select();
					email2.focus();
					return false;
				}
			
			if(phone2.value=="Phone")phone2.value="";
			if (emptyvalidation(phone2,"Woops! You forgot to fill your Phone Number")==false) 
			{
				phone2.select();
				phone2.focus();
				return false;
			}
			
					
			if(comments2.value=="Comments or Questions")comments2.value="";
			if (emptyvalidation(comments2,"Woops! You forgot to fill your Comments")==false) 
			{
				comments2.select();
				comments2.focus();
				return false;
			}
		
		thisform.submit();
				
	}
	
}
function emptyvalidation(entered, alertbox)
{
		
	with (entered)
	{
		
	
		while (value.charAt(0) == ' ')
			value = value.substring(1);
		while (value.charAt(value.length - 1) == ' ')
			value = value.substring(0, value.length - 1);
		if (value==null || value=="")
		{
			if (alertbox!="") alert(alertbox);
			return false;
		}
		else return true;
	}
}

function emailvalidation(entered,alertbox)
{
	with (entered)
	{
		lastpos=value.length-1;//Total Letters
		apos=value.indexOf("@"); //Total letters before @
		dotpos=value.lastIndexOf(".");//Total letters before .
		beforeStr=value.substring(0,apos);
		afterStr=value.substring(apos);
		dotafatpos=afterStr.indexOf(".");
		udslpos=beforeStr.lastIndexOf("_");
		dotfpos=beforeStr.indexOf(".");
		dotlpos=beforeStr.lastIndexOf(".");
		if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2 || dotfpos!=dotlpos || apos-1==udslpos || dotafatpos==1) 
		{if (alertbox) {alert(alertbox);} return false; }
		else {return true;}
	}
}

 

