 
	  function formValidation(thisform)
{ 
	with (thisform)
	{ 
			$('#submit_btn').hide();$('#wait_btn').show();
			if(fname.value=="Name")fname.value="";		
			if (emptyvalidation(fname,"Woops! You forgot to fill your Name")==false) 
			{
				fname.select();
				fname.focus();
				$('#submit_btn').show();$('#wait_btn').hide();
				return false;
			}
			if(address.value=="Address")address.value="";
			if (emptyvalidation(address,"Woops! You forgot to fill your Address")==false) 
			{
				address.select();
				address.focus();
				$('#submit_btn').show();$('#wait_btn').hide();
				return false;
			}
			if(email2.value=="Email")email2.value="";		
			if (emptyvalidation(email2,"Woops! You forgot to fill your Email")==false) 
			{
				email2.select();
				email2.focus();
				$('#submit_btn').show();$('#wait_btn').hide();
				return false;
			}
			
				if(emailvalidation(email2)==false)
				{
					alert("Woops! You have entered an invalid Email Address");
					email2.select();
					email2.focus();
					$('#submit_btn').show();$('#wait_btn').hide();
					return false;
				}
			
			if(phone2.value=="Phone")phone2.value="";
			if (emptyvalidation(phone2,"Woops! You forgot to fill your Phone Number")==false) 
			{
				phone2.select();
				phone2.focus();
				$('#submit_btn').show();$('#wait_btn').hide();
				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();
				$('#submit_btn').show();$('#wait_btn').hide();
				return false;
			}
		
			if(userdigit2.value=="Enter Verification Code")userdigit2.value="";
			if (emptyvalidation(userdigit2,"Woops! You forgot to fill  Verification Code")==false) 
			{
				userdigit2.select();
				userdigit2.focus();
				$('#submit_btn').show();$('#wait_btn').hide();
				return false;
			}
		 runAjax2('check_captcha2','process_mail.php',document.contact_form.userdigit2.value);
		 return false;
 }
 return true;
}
function captcha_refresh2()
{
document.getElementById("button_div2").src='button.php?'+Math.random();
return false;
}
<!--Ajax for checking the captcha code ends here -->
var xmlHttp
function runAjax2(field,argurl,argVal)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
} 
var url=argurl
url=url+"?userdigit="+argVal
url=url+"&sid="+Math.random()
if(field=='check_captcha2')
xmlHttp.onreadystatechange=check_captcha2;
xmlHttp.open("POST",url,true)
xmlHttp.send(null)
}
function check_captcha2() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
			
			if(xmlHttp.responseText=="yes")
			{
				$('#submit_btn').hide();$('#wait_btn').show();
			 	document.contact_form.submit();
			}
			else
			{
				captcha_refresh2();
				alert("Verification Code Mismatch");
				document.contact_form.userdigit2.focus();
				document.contact_form.userdigit2.select();
				$('#submit_btn').show();$('#wait_btn').hide();
				return false;
			}
			
	} 
} 
function GetXmlHttpObject()
{ 
	var objXMLHttp=null
if (window.XMLHttpRequest)
{
	objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
	return objXMLHttp
}

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;}
	}
}

 

