function formvalidation(thisform)
{
	var phone1element =  document.getElementById("phone1");
	var phone2element =  document.getElementById("phone2");
	with (thisform)
	{
		
		if(emptyvalidation(fname,"Woops! You forgot to fill in your first name")==false) 
			{
			fname.focus();
			return false;
			}
			if(emptyvalidation(lname,"Woops! You forgot to fill in your last name")==false) 
			{
			lname.focus();
			return false;
			}
		
		if(emptyvalidation(email,"Woops! You forgot to fill in your email address")==false) 
			{
			email.focus();
			return false;
			}
		if(emailvalidation(email,"Woops! You have entered an invalid Email Address")==false)
		{
			email.select();
			email.focus();
			return false;
		}
		
		
		if (emptyvalidation(phone,"Please enter your area code and full phone number (xxx xxx xxxx) in order to submit your form. Thank you!")==false) 
				{
					
					phone.focus();
					return false;
				}
		else
		 {
		      
				 for(var i=0;i<phone.value.length;i++)
				  {
					  if(!isDigit(phone.value.charAt(i)))
					  {
						alert("Please enter your area code and full phone number (xxx xxx xxxx) in order to submit your form. Thank you!");
						phone.select();
						return false;
					  }
				  }
				
		 }
		  if(phone.value.length<3)
		 {
		   alert("Please enter your area code and full phone number (xxx xxx xxxx) in order to submit your form. Thank you!");	
		   phone.focus();
		   return false;
		 }
		 
		 
				if(phone1element.value == "" )
			{
				alert("Please enter your area code and full phone number (xxx xxx xxxx) in order to submit your form. Thank you!");
				phone1element.focus();
				return false;
			}

           else
		 {
		      
				 for(var i=0;i<phone1element.value.length;i++)
				  {
					  if(!isDigit(phone1element.value.charAt(i)))
					  {
						alert("Woops! Phone number cannot contain characters");
						phone1element.select();
						return false;
					  }
				  }
				
		 }
		  if(phone1element.value.length<3)
		 {
		   alert("Please enter your area code and full phone number (xxx xxx xxxx) in order to submit your form. Thank you!");	
		   phone1element.focus();
		   return false;
		 }
		 
		if(phone2element.value == "" )
			{
				alert("Please enter your area code and full phone number (xxx xxx xxxx) in order to submit your form. Thank you!");
				phone2element.focus();
				return false;
			}
		else
		 {
		      
				 for(var i=0;i<phone2element.value.length;i++)
				  {
					  if(!isDigit(phone2element.value.charAt(i)))
					  {
						alert("Woops! Phone number cannot contain characters");
						phone2element.select();
						return false;
					  }
				  }
				
		 }
		  if(phone2element.value.length<4)
		 {
		   alert("Please enter your area code and full phone number (xxx xxx xxxx) in order to submit your form. Thank you!");	
		   phone.focus();
		   return false;
		 }	

	}
	
	
	if (thisform.state.value=='') 
		{
			alert("Woops! You forgot to select your state");
			thisform.state.focus();
			return false;
		}

	if(thisform.comment.value=='Comments' || thisform.comment.value=='' ) 
	{	
		if(thisform.formsubmit.value=="N")
		{
		var agree=confirm("Continue Without Any Comments?");
				if(agree)
					{
						
							if(thisform.formsubmit.value=="Y")
								{
								alert("Please wait while the form is getting submitted");
								return false;
								}
								else
								{
									thisform.formsubmit.value="Y";
									document.getElementById("button_show_hide").innerHTML='<img src="images/loading.gif" alt="" />';
			                       runAjax('check_captcha','process_mail.php','sendmail');
			                        return false;
									//thisform.submit();
								}
					}
					else
					{
						thisform.comment.focus();
						return false;
					}		
		}
		
	}
	else
	{
	if(thisform.formsubmit.value=="Y")
	{
		
		document.getElementById("button2").style.display='none';
		alert("Please wait while the form is getting submitted");
		return false;
	}
	else
	{
		
		thisform.formsubmit.value="Y";
		thisform.submit();
		//document.getElementById("button_show_hide").innerHTML='<img src="images/loading.gif" alt="" style="margin-bottom:10px"/>';
		//runAjax('check_captcha','process_mail.php','sendmail');
		
	}
}
}
<!--Ajax for checking the captcha code starts here -->

var xmlHttp

function runAjax(field,argurl,argVal)

{

//document.getElementById("check_captcha").innerHTML=" Loading...";

xmlHttp=GetXmlHttpObject()

if (xmlHttp==null)

{

alert ("Browser does not support HTTP Request")

return

} 

var url=argurl

url=url+"?verify_digit="+argVal
url=url+"&sid="+Math.random()
if(field=='check_captcha')
xmlHttp.onreadystatechange=check_captcha;
xmlHttp.open("GET",url,true)
xmlHttp.send(null)

}

function check_captcha() 

{ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

	{ 

			

			if(xmlHttp.responseText=="yes")

			{
				
					document.form1.submit();
					return true;

				

			}
			else
			{
				
				
					document.form1.submit();
					return true;
				
			
			}

			

			

	} 

} 



function GetXmlHttpObject()

{ 

	var objXMLHttp=null

if (window.XMLHttpRequest)

{

	objXMLHttp=new XMLHttpRequest()

}

else if (window.ActiveXObject)

{

	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")

}

	return objXMLHttp

}

<!--Ajax for checking the captcha code ends here -->
function isDigit(num)
{
	 if(num.length>1)
	   {
		return false;
	   }
    var string="1234567890";

	 if(string.indexOf(num)!=-1)
	  {
	   return true;
	  }
 return false;
}
