// JavaScript Document

function validate()
{
	
	if(document.frm.first.value=="") 
	{
		 alert("Please enter firstname");
		 document.frm.first.focus();
		 return;
		 
	}
	if(document.frm.first.value!= "")
	{
		if (isNaN(document.frm.first.value) != true)
		{
			alert("invalid firstname");
			document.frm.first.focus();
			return false;
			}
	}
	if(document.frm.last.value=="")
	{
		alert("please enter lastname");
		document.frm.last.focus();
		return;
	}
	if(document.frm.last.value!= "")
	{
		if (isNaN(document.frm.last.value) != true)
		{
			alert("invalid lastname");
			document.frm.last.focus();
			return false;
		}
	}
	if(document.frm.address.value!= "")
	{
		if (isNaN(document.frm.address.value) != true)
		{
			alert("invalid address");
			document.frm.address.focus();
			document.frm.address.select();
			return false;
		}
	}
	if (document.frm.phone.value!= "")
			{  
				if (isNaN(document.frm.phone.value) == true)
				{
					alert("Invalid phone No"); 
					document.frm.phone.focus();
					document.frm.phone.select();
					return false;
				}	 
			}
	 if(document.frm.email.value=="")
     {
        alert("E-mail cannot be blank");
		document.frm.email.focus();
	    return;	  
     }	
     var str=document.frm.email.value;
     var flag=0;
	 len=str.length;
	 //document.write(str);
	 for(i=1;i<len;i++)
	 {
	    if(str.charAt(i)=="@")
	    { 
	       for(i=i;i<len;i++)
		   {
		      if(str.charAt(i)==".")
	          {  
		         var len1=len-i;
			     if(len1>2)
			     {
		            flag=1;
		            break;
			     }
		      }
		   }
	    }
	 }
	 if(flag==0)
	{
	     alert("You have entered invalid E-mail Address");
		 document.frm.email.focus();
		 document.frm.email.select();
		 return;
	}	 
	  if(document.frm.country.value=="Select")
	  {
		 alert("Please select Country"); 
		 document.frm.country.focus();
		  return;
	  }
	  if(document.frm.feedback.value=="")
	 {
		 alert("Please fill up the feedback");
		  document.frm.feedback.focus();
		 return;
		 
	 }
	 if(document.frm.feedback.value!= "")
	{
		if (isNaN(document.frm.feedback.value) != true)
		{
			alert("invalid feedback");
			document.frm.feedback.focus();
			return false;
		}
	}
		document.frm.action="scripts/insertNmail.asp";
	    document.frm.submit() 
	 
	
	
}
	
	
	
	
	
	
	
	
	
	
	
	