
function check(){			
	var formcheck=document.myform.name.value;	
	var formcheck1=document.myform.email.value;	
	var formcheck2=document.myform.address.value;	
	var formcheck3=document.myform.persons.value;	

	var message = "";	

	var flag =0;
		
	if(formcheck=="" || formcheck1=="" || formcheck2==""  || formcheck3=="" )	{			
		flag=1;			
		
		if(formcheck=="")	
		 {			 	
			if(message!="")			 		
				message+=",";				
			else
				document.myform.name.focus();	

			message+=" name";				
					
		 }						
							
		if(formcheck1=="")			 
		{			 	
			if(message!="")			
			 	message+=",";			
			else
				document.myform.email.focus();	

			message+=" email";			
				
		}	

		if(formcheck2=="")			 
		{			 	
			if(message!="")			 		
				message+=",";	
			else
				document.myform.address.focus();

			message+=" address";				
			
		 }	
			
		if(formcheck3=="")		
		 {			 	
			if(message!="")			 	
				message+=",";			
			else
				document.myform.persons.focus();

			message+=" no of persons";			
			
		}

		alert('Please fill up your ' +message + ".");		
		return (false);	
	}	
	
	
	if(chkValidate(formcheck) == false){
					alert("Special character is not allowed.");
					document.myform.name.value="";
					document.myform.name.focus();

					return (false);

			}
	if(chkValidate(formcheck2) == false){
					alert("Special character is not allowed.");
					document.myform.address.value="";
					document.myform.address.focus();

					return (false);

			}	
	
	if(IsNumeric(formcheck3) == false){
					alert("Type only numbers.");
					document.myform.persons.focus();
					document.myform.persons.value="";
					return false;
			}

	
	if(flag==0){	
		if(formcheck1.indexOf(" ") >= 0 )		
		{			
			alert("Please enter the E-Mail address without any white space character.");			
			document.myform.email.focus();			
			return (false);		
		}				
		
		AtRateCheckfrom = formcheck1.indexOf("@");		
		AtDotCheckfrom  = formcheck1.indexOf(".");				
		AtRateCheckLastfrom = formcheck1.lastIndexOf("@");		
		AtDotCheckLastfrom = formcheck1.lastIndexOf("."); 				
		
		if ( (AtRateCheckfrom == -1) || (AtDotCheckfrom == -1) && flag==0){
			alert("Please enter your valid email-id"); 			
			document.myform.email.focus();	
			return (false);		
		}	

		if( (AtRateCheckLastfrom != AtRateCheckfrom)  && flag==0)		
		{			
			alert("Please enter your valid email-id"); 			
			document.myform.email.focus();			
			return (false);		
		}		
		
		BeforeAtRatefrom = formcheck1.substring(0,formcheck1.indexOf("@"));		
		AfterAtRatefrom = formcheck1.substring(formcheck1.indexOf("@")+1,formcheck1.length);

		if (AfterAtRatefrom.indexOf(".") == -1 && flag==0){			
			alert("Please enter your valid email-id"); 			
			document.myform.email.focus();			
			return (false);		
		}				
		
		middlefrom = AfterAtRatefrom.substring(0, AfterAtRatefrom.indexOf("."))	
		lastfrom = AfterAtRatefrom.substring(AfterAtRatefrom.indexOf(".") + 1,AfterAtRatefrom.length)	

		if (BeforeAtRatefrom.length == 0 || middlefrom.length == 0 || lastfrom.length == 0 && flag==0)	
		{			
			alert("Please enter your valid E-Mail"); 			
			document.myform.email.focus();		
			return (false);		
		}	
		else	
		{	 
			document.myform.submit();		
			return (true);	
					
		}	
	}	
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

function chkValidate(sText)
{
   var InvalidChars = "~!@#$%^&*()-+=|\/<>";
   var IsValid=true;
   var Char;

 
   for (i = 0; i < sText.length && IsValid == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (InvalidChars.indexOf(Char) > 0) 
         {
         IsValid = false;
         }
      }
   return IsValid;
   
   }