function  formvalidation(thisform)
{ 
	with (thisform)
	{ 
			if(name.value=="name")name.value="";		
			if (emptyvalidation(name,"Woops! You forgot to fill in your Name")==false) 
			{
				name.select();
				name.focus();
				return false;
			}
			
			if(email.value=="email")email.value="";		
			if (emptyvalidation(email,"Woops! You forgot to fill in your  Email Address")==false) 
			{
				email.select();
				email.focus();
				return false;
			}
			
			if(emailvalidation(email)==false)
			{
				alert("Woops! You have entered an invalid Email Address");
				email.select();
				email.focus();
				return false;
			}
			
		
			if(phone.value=="phone")phone.value="";
			if (emptyvalidation(phone,"Woops! You forgot to fill in your  Phone Number")==false) 
			{
				phone.select();
				phone.focus();
				return false;
			}
			
				if(comments.value=="comments")comments.value="";
			if (emptyvalidation(comments,"Woops! You forgot to fill in your Comments")==false) 
			{
				comments.select();
				comments.focus();
				return false;
			}
			
		thisform.submit();
	}
}
function emailvalidation(entered) 
 {
	
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = entered.value;
   if(reg.test(address) == false)
   {
	   return false;
   }
  }

 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=="")
		{
			//document.getElementById("message").innerHTML="Please enter Required Field";
			if (alertbox!="") alert(alertbox);
			return false;
		}
		else return true;
	}
}

 

