// Form Validation

function validate()
{

		///*validation name field*///

		if (document.queryform.name.value=="")
		{
		 alert("Please enter your name.")
	     document.queryform.name.focus();
		  return false;
	   	}
		
	 	if(document.queryform.name.value!="")
		{
		var alphaExp = /^[a-zA-Z""]+$/; 
		 if(document.queryform.name.value.search(alphaExp)==-1)
		 {
        	 alert("Invalid character in name field.")
	   		document.queryform.name.value="";
			document.queryform.name.focus();

		   return false;
			 }
		 }
		
	   
         /*validation email field*/
		 
		 
 var emailID=document.queryform.email
	
	if ((emailID.value==null)||(emailID.value==""))
	{
		alert("E-mail ID  is blank, please fill it.")
		document.queryform.email.focus();
		emailID.focus()
		  return false;
	}
	if (echeck(emailID.value)==false)
	{
		//emailID.value=""
			alert("Please enter your E-mail ID in right format.")
		emailID.focus()
		  return false;
	}
		
		
		/*validation enquiry field*/
			
	

		

		
		
		
		///*validation comment field*///
		
		if (document.queryform.msg.value=="")
		{
		 alert("Please enter your Message.")
		  document.queryform.msg.value="";
	     document.queryform.msg.focus();
		  return false;
	   	}
}
		
	   
		
	 
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
        var loc;
        var pos;        
		
		loc=(str.search(/@/));
	    pos=(str.slice(0,loc));
		
        if(!isNaN(pos))
		{
			alert("Invalid Email Id ")
		   return false
		}
	   
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
	
	
	
