function validate(form_name,parameter,color,type)
{	

	if(color=="")
	{
		color="#FF0000";
	}
	var value=new Array();
	
	var combo=new Array();
	
	

			
	for(k=0;k<parameter.length;k++)//----------- Validate the parameter array()-----------------
	{		
				
				
	   if(check(form_name,parameter[k][0],parameter[k][1],parameter[k][2],color,parameter[k][3],parameter[k][4],parameter[k][5],parameter[k][6])==1)//------ calling the check() function --------------------
		{
			
			value[k]=1;
		
													
		}
		else
		{
			if(parameter[k][1]=="" || parameter[k][6]=="e" || parameter[k][1]=="depend")
			{
				value[k]="nf";
				
				combo[k]=parameter[k][0];
															
			}
			else
			{
				value[k]=parameter[k][0];
				
							
			}
		}
		
		
		
		if(type=="one")
		{
		
					
			if(value[k]!=1)
			{
			
			
				if(value[k]!="nf")
				{
					foc="document."+form_name+"."+value[k];
					
					c=value[k];
					
					eval(foc).focus();
					
					eval(foc).style.background='yellow';
					
				}
				if(value[k]=="nf")
				{
					foc="document."+form_name+"."+combo[k];
					
					c=combo[k];
					
					eval(foc).focus();
					
					eval(foc).style.background='yellow';
					
				}
				
				for(kj=0;kj<parameter.length;kj++)
	                        {
	                        
	                          value[kj]=parameter[kj][0];		
				
				      if(c!=value[kj])
				      {
						    				
				       foc="document."+form_name+"."+value[kj];
										
					eval(foc).style.background='white';
					
				      }
					
				}
				
								
				
					return false;
			}
								
			
			
		}		
	}
	
   	return result(form_name,value);//---------- call result() for checking all elements in the form are validated 
}

//validate(formname,fieldname,property,err_lab_id,err_color_code,err_message,allowed)

function check(form,element,reg,lab_id,color1,err_message,allowed,length,space)
{
	
	temp="document."+form+"."+element;

	var err=document.getElementById(lab_id);

	temp2="document."+form+"."+element+"[0]";
	
	error=err_message.split('#$#');

	if(error.length==2)
	{
		err_message=error[0];
	}
	if(reg=="depend")
	{	
		dep_elem=element.split('#$#');

		dep_lab=lab_id.split('#$#');

		dep_err=err_message.split('#$#');

		j=1; //all empty

		f=1; // all are filled

		for(e=0;e<dep_elem.length;e++)
		{
			dep_val="document."+form+"."+dep_elem[e];

			if(eval(dep_val).value!="")

				j=0;

			if(eval(dep_val).value=="")
			{
				f=0;	
			}		
		}
	
		if(j==1)

			return(1)

		else if(f==1)

			return(1);
		else
		{		
				for(e=0;e<dep_elem.length;e++)
				{
					dep_val="document."+form+"."+dep_elem[e];

					if(eval(dep_val).value=="")
					{
						err=document.getElementById(dep_lab[e]);

						err.innerHTML=dep_err[e];

						err.style.color=color1
					}		
				}
				return(0);
		}
	}	
else if(reg!="")
{
	if(eval(temp).value=="")
	{
		if(reg=="nws" || reg=="cws" || reg=="anws")
		{
			if(lab_id!="")
			{
				err.innerHTML="";
			}
			return(1);
		}
		if(space=="e")
		{
			if(lab_id!="")
			{
				err.innerHTML="";
			}
			return(1);
		}
		if(lab_id!="")
		{
		
			if(error.length!=2)
			{
				err.innerHTML="Enter the value";

				err.style.color=color1;
			}
			else
			{
				err.innerHTML=error[1];

				err.style.color=color1;
			}
		}
		return(2);

	
	}
	else if(reg=="n")
	{
		if(allowed=="")
		{
			var regs1=new RegExp("^[0-9]+$")
			var regs2=new RegExp("^[0-9]+$")
		}
		else
		{
			reg="^[0-9"+allowed+"]+$";
			var regs1=new RegExp(reg);
		}
		if(length!="")
		{   
			q=length.split(",")
		    r=eval(temp).value;
		
			if(r.length<=q[0])
			{
				if(lab_id!="")
				{
					err.innerHTML="The values should be greater than "+q[0]+" letters";
					err.style.color=color1;
				}
					return 0;		
			}
		   else if(r.length>=q[1])
			{
				if(lab_id!="")
				{
					err.innerHTML="The values should be lesser than "+q[1]+" letters";
					err.style.color=color1;
				}
					return 0;
			}
			else  if(regs2.exec(eval(temp).value))
			{
				if(eval(r)<q[2] || eval(r)>q[3])
				{
					if(lab_id!="")
					{
						err.innerHTML="The values should be in the range "+q[2]+" to "+q[3];
						err.style.color=color1;
					}
						return 0;
				}
			}
			else
			{
				if(lab_id!="")
				{
					err.innerHTML="";
				
				}
			

			}
		}	
	
	    if(regs1.exec(eval(temp).value))
	    {
			if(lab_id!="")
			{
				err.innerHTML="";
			
			}
				    return(1);
		}
		else
		{
		
		       if(lab_id!="")
			   {
					if(err_message!="")
					{
						err.innerHTML=err_message;
						err.style.color=color1;
					}
					else
					{
						err.innerHTML="Enter numbers only";
						err.style.color=color1;
				    }
				}
					  
			       return(0);
		}
	}
	else if(reg=="decimal")
	{

			if(allowed=="")
			{

		   		var regs1=new RegExp("^(\\d+)(\\.)(\\d{2})$")
			}
			else
			{
				reg="^(\\d+)(\\.)(\\d{"+allowed+"})$";

				var regs1=new RegExp(reg);
			}
			if(length!="")
			{   
				q=length.split(",")

			    	r=eval(temp).value;
		
				if(r.length<=q[0])
				{
					if(lab_id!="")
					{
						err.innerHTML="The values should be greater than "+q[0]+" letters";

						err.style.color=color1;
					}
						return 0;		
				}
				if(r.length>=q[1])
				{
					if(lab_id!="")
					{
						err.innerHTML="The values should be lesser than "+q[1]+" letters";

						err.style.color=color1;
					}
						return 0;	
				}
			}
	
		    if(regs1.exec(eval(temp).value))
		    {
				if(lab_id!="")
				{
					err.innerHTML="";

					err.style.color=color1;
				}
			   return(1);
			}
		   else
		   {
			       if(lab_id!="")
				   {
						if(err_message!="")
						{
							err.innerHTML=err_message;

							err.style.color=color1;
						}
						else
						{
							err.innerHTML="Enter decimal only";

							err.style.color=color1;
					    }
					}
						  
				       return(0);
			}
	}
	else if(reg=="c")
	{
		     
		if(allowed=="")
		{
			var regs1=new RegExp("^[a-zA-Z]+$")
	        }
		else
	    	{			
	 		reg="^[a-zA-Z"+allowed+"]+$";

			var regs1=new RegExp(reg)			   
	    	}
	
		if(length!="")
		{   
			q=length.split(",")

		    	r=eval(temp).value;
		
			if(r.length<=q[0])
			{
				if(lab_id!="")
				{
					err.innerHTML="The values should be greater than "+q[0]+" letters";

					err.style.color=color1;
				}
					return 0;		
			}
			if(r.length>=q[1])
			{
				if(lab_id!="")
				{
					err.innerHTML="The values should be lesser than "+q[1]+" letters";

					err.style.color=color1;
				}
					return 0;	
			}
		}

	   	if(regs1.exec(eval(temp).value))
		{
				if(lab_id!="")
			    	{
					err.innerHTML="";

					err.style.color=color1;
			    	}
				 return(1);		
		}
		else
		{
			if(lab_id!="")
			{
				if(err_message!="")
				{
					err.innerHTML=err_message;

					err.style.color=color1;
			    }
			    else 
			    {
					err.innerHTML="Enter characters only";

					err.style.color=color1;
			    }
			}
			   
			 return(0);
		}
	}
	else if(reg=="cl")
	{
	     
		if(allowed=="")
		{
		       	     var regs1=new RegExp("^[a-z]+$")
		}
		else
		{			
			     reg="^[a-z"+allowed+"]+$";

			     var regs1=new RegExp(reg)			   
	        }
		
		if(length!="")
		{   
			q=length.split(",")

		    	r=eval(temp).value;
		
			if(r.length<=q[0])
			{
				if(lab_id!="")
				{
					err.innerHTML="The values should be greater than "+q[0]+" letters";

					err.style.color=color1;
				}
					return 0;		
			}
			if(r.length>=q[1])
			{
				if(lab_id!="")
				{
					err.innerHTML="The values should be lesser than "+q[1]+" letters";

					err.style.color=color1;
				}
					return 0;	
			}
		}		
	
		if(regs1.exec(eval(temp).value))
		{
			if(lab_id!="")
			{
				err.innerHTML="";

				err.style.color=color1;
		    	}
			 return(1);		
		}
		else
		{
			if(lab_id!="")
			{
				if(err_message!="")
				{
					err.innerHTML=err_message;

					err.style.color=color1;
			    	}
			    	else 
			    	{
					err.innerHTML="Enter Lowercase characters only";

					err.style.color=color1;
			    	}
			}
			   
			 return(0);
		}
	}
else if(reg=="cu")
{
	     
	if(allowed=="")
	{
		var regs1=new RegExp("^[A-Z]+$")
    	}
	else
	{			
		reg="^[A-Z"+allowed+"]+$";

        	var regs1=new RegExp(reg)			   
	}

	if(length!="")
	{   
		q=length.split(",")

	    	r=eval(temp).value;
		
		if(r.length<=q[0])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be greater than "+q[0]+" letters";

				err.style.color=color1;
			}
				return 0;		
		}
		if(r.length>=q[1])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be lesser than "+q[1]+" letters";

				err.style.color=color1;
			}
				return 0;	
		}
	}
	
	if(regs1.exec(eval(temp).value))
	{
		if(lab_id!="")
		{
			err.innerHTML="";
		        err.style.color=color1;
		}

                return(1);		
    	}
	else
	{
		if(lab_id!="")
		{
				if(err_message!="")
				{
					err.innerHTML=err_message;

				    	err.style.color=color1;
			    	}
				    else 
				    {
						err.innerHTML="Enter Uppercase characters only";

						err.style.color=color1;
				    }
		}
			  
			 return(0);
	     }
}
else if(reg=="an")
{
	   
        	 if(allowed=="")
		 {
	       			var regs1=new RegExp("^[\\w]+$")
		  }
		else
		   {
           			reg="^[\\w"+allowed+"]+$";

		   		var regs1=new RegExp(reg)
		   }
		  
	if(length!="")
	{   
		q=length.split(",")

	    	r=eval(temp).value;
		
		if(r.length<=q[0])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be greater than "+q[0]+" letters";

				err.style.color=color1;
			}
				return 0;		
		}
		if(r.length>=q[1])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be lesser than "+q[1]+" letters";

				err.style.color=color1;
			}
				return 0;	
		}
	}		
	if(regs1.exec(eval(temp).value))
    	{
		if(lab_id!="")
		{
	         	err.innerHTML="";

	         	err.style.color=color1;
		}
	         return(1);		
    	}
    	else
    	{
		if(lab_id!="")
		{
			if(err_message!="")
			{
				err.innerHTML=err_message;

				err.style.color=color1;
		    	}
		    else 
		    {
				err.innerHTML="Enter Alphanumeric only";

				err.style.color=color1;
		    }
		}
			
	         return(0);
			  
	}
}
else if(reg=="nws")
{
		if(allowed=="")
		{
			var regs1=new RegExp("^[0-9\\s]+$")
	    	}
	    else
	    {
			reg="^[0-9\\s"+allowed+"]+$";

			var regs1=new RegExp(reg)   
	    }

	if(length!="")
	{   
		q=length.split(",")

	    	r=eval(temp).value;
		
		if(r.length<=q[0])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be greater than "+q[0]+" letters";

				err.style.color=color1;
			}
				return 0;		
		}
		if(r.length>=q[1])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be lesser than "+q[1]+" letters";

				err.style.color=color1;
			}
				return 0;	
		}
	}

     if(regs1.exec(eval(temp).value))
    {
		if(lab_id!="")
		{
			err.innerHTML="";

	        	err.style.color=color1;
	       }
	         return(1);		
	}
	else
	{ 
		if(lab_id!="")
		{
			if(err_message!="")
			{
				err.innerHTML=err_message;

				err.style.color=color1;
		    	}
		    else 
			{
				err.innerHTML="Enter numbers or numbers with space";

				err.style.color=color1;
		    	}
		}
			
	         return(0);
	}
}
else if(reg=="ns")
{
	if(space=="s")
	{
		if(eval(temp).length==0)
		{
			
			err.innerHTML="";
		}
	}
	if(allowed=="")
	{
		var regs1=new RegExp("^[0-9\\s]{1,100}+$")
    	}
	    else
	    {
			reg="^[0-9\\s"+allowed+"]{1,100}$";

			var regs1=new RegExp(reg)   
	    }

	if(length!="")
	{   
		q=length.split(",")

	   	r=eval(temp).value;
		
		if(r.length<=q[0])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be greater than "+q[0]+" letters";

				err.style.color=color1;
			}
				return 0;		
		}
		if(r.length>=q[1])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be lesser than "+q[1]+" letters";

				err.style.color=color1;
			}
				return 0;	
		}
	}

	if(regs1.exec(eval(temp).value))
    	{
		if(lab_id!="")
		{
			err.innerHTML="";

	        	err.style.color=color1;
	    	}
	         return(1);		
	}
	else
	{ 
		if(lab_id!="")
		{
			if(err_message!="")
			{
				err.innerHTML=err_message;

				err.style.color=color1;
		        }
		    else 
			{
				err.innerHTML="Enter numbers or numbers with space";

				err.style.color=color1;
		         }
		}
			
	         return(0);
	}
}
else if(reg=="cws")
{
	if(allowed=="")
	{
		var regs1=new RegExp("^[a-zA-z\\s]+$")
	}
	else
	{
		reg="^[a-zA-z\\s"+allowed+"]+$";

	    	var regs1=new RegExp(reg)   
	}

	if(length!="")
	{   
		q=length.split(",")

	    	r=eval(temp).value;
		
		if(r.length<=q[0])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be greater than "+q[0]+" letters";

				err.style.color=color1;
			}
				return 0;		
		}
		if(r.length>=q[1])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be lesser than "+q[1]+" letters";

				err.style.color=color1;
			}
				return 0;	
		}
	}

	if(regs1.exec(eval(temp).value))
	{
		if(lab_id!="")
		{
			 err.innerHTML="";

			 err.style.color=color1;
		}
	         return(1);		
	}
    else
	{ 
		if(lab_id!="")
		{
			if(err_message!="")
			{
				err.innerHTML=err_message;

				err.style.color=color1;
		    	}
    			else 
			{			
				err.innerHTML="Enter characters or characters with space";

				err.style.color=color1;
			}
	   	}
			
	         return(0);
    }
}
else if(reg=="cs")
{
	if(allowed=="")
	{
		var regs1=new RegExp("^[a-zA-z\\s]{1,100}$")
	}
	else
	{
		reg="^[a-zA-z\\s"+allowed+"]{1,100}$";

	    	var regs1=new RegExp(reg)   
	}

	if(length!="")
	{   
		q=length.split(",")

	    	r=eval(temp).value;
		
		if(r.length<=q[0])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be greater than "+q[0]+" letters";

				err.style.color=color1;
			}
				return 0;		
		}
		if(r.length>=q[1])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be lesser than "+q[1]+" letters";

				err.style.color=color1;
			}
				return 0;	
		}
	}

	if(regs1.exec(eval(temp).value))
	{
		if(lab_id!="")
		{
			 err.innerHTML="";

			 err.style.color=color1;
		}
	         return(1);		
	}
    else
	{ 
		if(lab_id!="")
		{
			if(err_message!="")
			{
				err.innerHTML=err_message;

				err.style.color=color1;
		    	}
    			else 
			{			
				err.innerHTML="Enter characters or characters with space";

				err.style.color=color1;
			}
	   }
			
	         return(0);
    }
}
else if(reg=="cls")
{
	     
	if(allowed=="")
	{
		var regs1=new RegExp("^[^\\s][a-z\\s]+$")
	}
	else
	{			
		reg="^[^\\s][a-z\\s"+allowed+"]+$";

		var regs1=new RegExp(reg)			   
	}

	if(length!="")
	{   
		q=length.split(",")

	    	r=eval(temp).value;
		
		if(r.length<=q[0])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be greater than "+q[0]+" letters";

				err.style.color=color1;
			}
				return 0;		
		}
		if(r.length>=q[1])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be lesser than "+q[1]+" letters";

				err.style.color=color1;
			}
				return 0;	
		}
	}
	if(regs1.exec(eval(temp).value))
	{
		if(lab_id!="")
		{
			 err.innerHTML="";

			 err.style.color=color1;
		}
	         return(1);		
    	}
	else
	{
		if(lab_id!="")
		{
			if(err_message!="")
			{
				err.innerHTML=err_message;

				err.style.color=color1;
		    	}
			    else 
			    {
					err.innerHTML="Enter Lowercase characters or Lowercase characters with space ";
					err.style.color=color1;
			    }
		}
		   
	         return(0);
   }
}
else if(reg=="cus")
{
	     
	if(allowed=="")
	{
		var regs1=new RegExp("^[^\\s][A-Z\\s]+$")
    	}
	else
	{			
		reg="^[^\\s][A-Z\\s"+allowed+"]+$";

		var regs1=new RegExp(reg)			   
    	}
		if(length!="")
		{   
			q=length.split(",")

			r=eval(temp).value;
		
			if(r.length<=q[0])
			{
				if(lab_id!="")
				{
					err.innerHTML="The values should be greater than "+q[0]+" letters";

					err.style.color=color1;
				}
					return 0;		
			}
			if(r.length>=q[1])
			{
				if(lab_id!="")
				{
					err.innerHTML="The values should be lesser than "+q[1]+" letters";

					err.style.color=color1;
				}
					return 0;	
			}
		}
	if(regs1.exec(eval(temp).value))
	{
		if(lab_id!="")
		{
			 err.innerHTML="";

			 err.style.color=color1;
		}
	         return(1);		
    }
	else
	{
		if(lab_id!="")
		{
			if(err_message!="")
			{
				err.innerHTML=err_message;

				err.style.color=color1;
			}
			else 
			{
				err.innerHTML="Enter Upperrcase characters or Uppercase characters with space";

				err.style.color=color1;
			}
		}
		  
	         return(0);
   }
}
else if(reg=="anws")
{
	if(allowed=="")
	{
		var regs1=new RegExp("^[\\w\\s]+$")
    	}
	else
	{
        	reg="^[\\w\\s"+allowed+"]+$";

	    	var regs1=new RegExp(reg)   
	}

	if(length!="")
	{   
		q=length.split(",")

	    	r=eval(temp).value;
		
		if(r.length<=q[0])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be greater than "+q[0]+" letters";

				err.style.color=color1;
			}
				return 0;		
		}
		if(r.length>=q[1])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be lesser than "+q[1]+" letters";

				err.style.color=color1;
			}
				return 0;	
		}
	}
	if(regs1.exec(eval(temp).value))
	{
		if(lab_id!="")
		{
			 err.innerHTML="";

			 err.style.color=color1;
		}
	         return(1);		
       }
       else
       { 
		if(lab_id!="")
        	{
		    	if(err_message!="")
			{
					err.innerHTML=err_message;

					err.style.color=color1;
			}
			else 
			 {
					err.innerHTML="Enter alphanumeric or alphanumeric with space";

					err.style.color=color1;
			 }
		}
			
	         return(0);
	}
}
else if(reg=="ans")
{
	if(allowed=="")
	{
		var regs1=new RegExp("^[\\w\\s]{1,100}$")
    	}
	else
	{
		reg="^[\\w\\s"+allowed+"]{1,100}$";

		var regs1=new RegExp(reg)   
	}

	if(length!="")
	{   
		q=length.split(",")

	    	r=eval(temp).value;
		
		if(r.length<=q[0])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be greater than "+q[0]+" letters";

				err.style.color=color1;
			}
				return 0;		
		}
		if(r.length>=q[1])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be lesser than "+q[1]+" letters";

				err.style.color=color1;
			}
				return 0;	
		}
	}
	if(regs1.exec(eval(temp).value))
	{
		if(lab_id!="")
		{
			 err.innerHTML="";

			 err.style.color=color1;
		}
	         return(1);		
    }
    else
    { 
		if(lab_id!="")
        	{
		    	if(err_message!="")
			{
					err.innerHTML=err_message;
							
					err.style.color=color1;
			}
			else 
			 {
					err.innerHTML="Enter alphanumeric or alphanumeric with space";

					err.style.color=color1;
			 }
		}
			
	         return(0);
	}
}
else if(reg=="sws")
{
	    
	var regs1=new RegExp("^\\s+")

	if(regs1.exec(eval(temp).value))
	{
		if(lab_id!="")
		{
			 err.innerHTML="";

			 err.style.color=color1;
		}
	         return(1);		
	}
	else
	{
		if(lab_id!="")
		{
			if(err_message!="")
			{
				err.innerHTML=err_message;

				err.style.color=color1;
		    	}
			else 
			{
				err.innerHTML="Enter values start with space";

				err.style.color=color1;
		    	}
		}
			
	         return(0);
	}
}
else if(reg=="ews")
{
	
            var regs1=new RegExp("\\s+$")

	    if(regs1.exec(eval(temp).value))
	       {
			 if(lab_id!="")
			   {
				 err.innerHTML="";

				 err.style.color=color1;
			   }

	         return(1);	
	
	       }
	    else
	       {
			 if(lab_id!="")
			   {
				 if(err_message!="")
				   {
             				err.innerHTML=err_message;

			 		err.style.color=color1;
				   }
				  else 
				   {
					 err.innerHTML="Enter values end with space";

					 err.style.color=color1;
				   }
			   }
			 
	         return(0);
	       }
	}
else if(reg=="address")
{	     
	if(allowed=="")
	{
		var regs1=new RegExp("^[\\w\\s\\/\\.\\,\\;\\-\\(\\)]+$")
    	}
	else
    	{			
 		reg="^[\\w\\s\\/\\.\\,\\;\\-"+allowed+"]+$";

        	var regs1=new RegExp(reg)			   
    	}
	
	if(length!="")
	{   
		q=length.split(",")

	    	r=eval(temp).value;
		
		if(r.length<=q[0])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be greater than "+q[0]+" letters";

				err.style.color=color1;
			}
				return 0;		
		}
		if(r.length>=q[1])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be lesser than "+q[1]+" letters";

				err.style.color=color1;
			}
				return 0;	
		}
	}

    if(regs1.exec(eval(temp).value))
	{
		if(lab_id!="")
	    	{
			err.innerHTML="";
	        	err.style.color=color1;
	    	}
	         return(1);		
	}
	else
	{
		if(lab_id!="")
		{
			if(err_message!="")
			{
				err.innerHTML=err_message;

				err.style.color=color1;
		    	}
		    else 
		    {
				err.innerHTML="Use / , ; . - Symbols  only";

				err.style.color=color1;
		    }
		}
		   
	         return(0);
	}
}
else if(reg=="email")
	{	
        	var regs1=new RegExp("^([a-zA-Z0-9]{1})+[A-Za-z0-9_\.]+@[A-Za-z0-9]+[\.]+[A-Za-z\.]+$")
			
		var regs2=new RegExp("^([a-zA-Z0-9]{1})+@+[A-Za-z0-9]+[\.]+[A-Za-z\.]+$")

		if(regs1.exec(eval(temp).value) || regs2.exec(eval(temp).value))
	       {
			 if(lab_id!="")
			   {
				 err.innerHTML="";

				 err.style.color=color1;
			   }
	         return(1);		
	       }
	    else
	       {
			 if(lab_id!="")
			   {
				 if(err_message!="")
				   {
             				err.innerHTML=err_message;

			 		err.style.color=color1;
				   }
				  else 
				   {
					 err.innerHTML="Invalid email";

					 err.style.color=color1;
                   		    }
			   }
			
	         return(0);
	       }
	}
   	else if(reg=="date")
	{

        	if(allowed.length==3)
		{
			  	  d1=allowed.charAt(0);

				  d2=allowed.charAt(1);

				  d3=allowed.charAt(2);
		}
		else
		{
				  d1=allowed.charAt(0);

				  d2=allowed.charAt(1);

				  d3=allowed.charAt(2);

				   s=allowed.charAt(3)+"{1}";
		}
                if(d1=="y")
				  {
					d1="^([0-9]{4})";
				  }
                else
				  {
					d1="^([0-9]{2})";
				  }
				if(d2=="y")
				  {
					d2="([0-9]{4})";
				  }
                else
				  {
					d2="([0-9]{2})";
				  }
				if(d3=="y")
				  {
					d3="([0-9]{4})$";
				  }
                else
				  {
					d3="([0-9]{2})$";
				  }
        if(allowed=="")
		  {			 
	      		var regs1=new RegExp("^([0-9]{2})\/{1}([0-9]{2})\/{1}([0-9]{4})$");
		  }
		else
		  {
				if(allowed.length==3)
				  {
				      	  s="/{1}";	
			
					  reg=d1+"\\"+s+d2+"\\"+s+d3;
				  }
			  	else
				  {
		      			  reg=d1+"\\"+s+d2+"\\"+s+d3;
				  }
			  		var regs1=new RegExp(reg);
		  }
       
	    if(regs1.exec(eval(temp).value))
	       { 
			 if(lab_id!="")
			   {
				 err.innerHTML="";

				 err.style.color=color1;
			   }
	         return(1);		
	       }
	    else
	       { 
			 if(lab_id!="")
			   {
				 if(err_message!="")
				   {
             				err.innerHTML=err_message;

			 		err.style.color=color1;
				   }
				  else 
				   {
					 err.innerHTML="Invalid date";

					 err.style.color=color1;
				   }
			   }
			 
	         return(0);
	       }
	}
	else if(reg=="name")
	{
		
        	var regs1=new RegExp("^[A-Za-z\\s]+[\.]+[A-Za-z\\s]+$")

		var regs2=new RegExp("^[A-Za-z\\s]+[\.]+[A-Za-z\\s]+[\.]+[A-Za-z\\s]+$")

	if(length!="")
	{   
		q=length.split(",")

	    	r=eval(temp).value;
		
		if(r.length<=q[0])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be greater than "+q[0]+" letters";

				err.style.color=color1;
			}
				return 0;		
		}
		if(r.length>=q[1])
		{
			if(lab_id!="")
			{
				err.innerHTML="The values should be lesser than "+q[1]+" letters";

				err.style.color=color1;
			}
				return 0;	
		}
	}		
			
		if(regs1.exec(eval(temp).value) || regs2.exec(eval(temp).value))
	       {
				if(lab_id!="")
			   	{
					err.innerHTML="";

					err.style.color=color1;
			   	}
	         return(1);		
	       }
	    else
	       {
			 if(lab_id!="")
			   {
				 if(err_message!="")
				   {
					err.innerHTML=err_message;

			        	err.style.color=color1;
				   }
				  else 
				   {
					 err.innerHTML="Invalid Name";

					 err.style.color=color1;
				   }
			   }
			 
	         return(0);
	       }
	}
else if(reg=="password")
	{
		if(allowed=="")
		{
			var regs1=new RegExp("^[\\w]+$")
    		}
	else
	{
        		reg="^[\\w"+allowed+"]+$";

	    		var regs1=new RegExp(reg)   
	}

	if(length!="")
	{   
		compare=length.split("#$#")

		if(compare.length==2)
		{
			length=compare[0];

			compare=compare[1];
		}
		q=length.split(",")

	    	r=eval(temp).value;

		if(r.length<q[0])
		{
			if(lab_id!="")
			{
				err.innerHTML="The password must be atleast "+q[0]+" letters";

				err.style.color=color1;
			}
				return 0;		
		}
		if(r.length>=q[1])
		{
			if(lab_id!="")
			{
				err.innerHTML="The Password should be lesser than "+q[1]+" letters";

				err.style.color=color1;
			}
				return 0;	
		}
        
	}
	if(regs1.exec(eval(temp).value))
	{
		compare="document."+form+"."+compare;

		if(eval(temp).value!=eval(compare).value)
		{
			if(lab_id!="")
			{
				 err.innerHTML="Password are not same";

				 err.style.color=color1;
			}
	         	return(0);			
		}
		if(lab_id!="")
		{
			 err.innerHTML="";

			 err.style.color=color1;
		}
	         return(1);		
    }
    else
    { 
		if(lab_id!="")
        	{
	    		if(err_message!="")
			{
				err.innerHTML=err_message;

				err.style.color=color1;
		    	}
		    	else 
		    	{
				err.innerHTML="Enter alphanumeric or alphanumeric with space";

				err.style.color=color1;
		    	}
		}
			
	         return(0);
	}

}
	else if(reg=="custom")
	{
		var regs1=new RegExp(allowed)

		if(length!="")
		{   
			q=length.split(",")

		    	r=eval(temp).value;
		
			if(r.length<=q[0])
			{
				if(lab_id!="")
				{
					err.innerHTML="The values should be greater than "+q[0]+" letters";

					err.style.color=color1;
				}
					return 0;		
			}
			if(r.length>=q[1])
			{
				if(lab_id!="")
				{
					err.innerHTML="The values should be lesser than "+q[1]+" letters";

					err.style.color=color1;
				}
					return 0;	
			}
		}		
		if(regs1.exec(eval(temp).value))
	       {
			 if(lab_id!="")
			   {
					err.innerHTML="";

					err.style.color=color1;
			   }
	         		return(1);
	      }
	    else
	       {
			 if(lab_id!="")
			   {
				 if(err_message!="")
				   {
					     err.innerHTML=err_message;

					     err.style.color=color1;
				   }
				  else 
				   {
						 err.innerHTML="Invalid ";

						 err.style.color=color1;
				   }
			   }
			
	         return(0);
	       }
	}
}
else
{

	reg=eval(temp).type;

	if(eval(temp).type==undefined)
	{	
        	temp1="document."+form+"."+element+"[0]";

	        reg=temp1;

		reg=eval(reg).type;		
	}
	

	var check=space.split("#$#")

	if(check[0]!="" && check[0]==eval(temp).value)
	{
			err.innerHTML="";

			return 1
	}
	
	if(reg=="select-one")
	{			
		if(eval(temp).selectedIndex!=0)
	       {

			if(check[1]==undefined)
			{
				if(lab_id!="")
			        {
					err.innerHTML="";

					err.style.color=color1;
			        }			   
				return(1);
			}
			else
			{
				new_elem="document."+form+"."+check[1];

			        new_val=new_elem;

				final_val=eval(new_val).value;

				if(eval(temp).value==final_val)
				{
					
					if(lab_id!="")
					{
						err.innerHTML=check[2];

						err.style.color=color1;
					}	
					return(0);
				}
				else
				{	
					if(lab_id!="")
					{
						err.innerHTML="";

						err.style.color=color1;
					}	
					return(1)
				}
			}
		  }
	    else
	       {
			 if(lab_id!="")
			   {
				 if(err_message!="")
				   {
						err.innerHTML=err_message;

						err.style.color=color1;
				   }
				  else 
				   {
					    					
						
						err.innerHTML="Select the value";

						err.style.color=color1;
						
				   }
			   }
			  return(0);
	       }
	}
	if(reg=="select-multiple")
	{			
		if(eval(temp).selectedIndex!=0)
	       {
			 if(lab_id!="")
			   {
	         		err.innerHTML="";

	         		err.style.color=color1;
			   }			   
	         		return(1);
	 	}
	    else
	       {
			 if(lab_id!="")
			   {
				 if(err_message!="")
				   {
             				err.innerHTML=err_message;

			 		err.style.color=color1;
				   }
				  else 
				   {
					  
						err.innerHTML="Select the value ";

						err.style.color=color1;
						
						
				   }
			   }
			  return(0);
	       }
	}
	else if(reg=="radio" || reg=="checkbox")
	{
		
		var s="";

		var m;

		if(eval(temp).length!=undefined)
		{
			for(m=0;m<eval(temp).length;m++)
			{
				temp2="document."+form+"."+element+"["+m+"]";

				if(m<eval(temp).length-1)
				{
					s+=eval(temp2).checked+" == false && ";				
				}
				else
				{
					s+=eval(temp2).checked+" == false";
				}
				
			}
			if(eval(s))
			{
				if(lab_id!="")
			   {
					if(err_message!="")
				   {
						err.innerHTML=err_message;

						err.style.color=color1;
				   }
				  else 
				   {						
						err.innerHTML="Select the value ";

						err.style.color=color1;
						
				   }
					
			   }			   
	           return(0);
			}
			else
			{
				if(lab_id!="")
			   {
					err.innerHTML="";

					err.style.color=color1;
			   }			   
	           return(1);	
			}			
		}
	    if(eval(temp).checked==true)
	    {
			 if(lab_id!="")
			   {
					err.innerHTML="";

					err.style.color=color1;
			   }			   
	         return(1);
		}   
	    else
	    {
			 if(lab_id!="")
			   {
				 if(err_message!="")
				   {
						err.innerHTML=err_message;

						err.style.color=color1;
				   }
				  else 
				   {
						err.innerHTML="Select the value ";

						err.style.color=color1;
				   }
			   }
			  return(0);
	     }
	}
}
}

function result(form_name,value1)
{	
	var t="";

	for(i=0;i<value1.length;i++)//-------------checking for true values -----------------------
	{
		if(value1[i]!=1)
	    {
			    if(value1[i]=="nf" )
			    {
			              
			              	return false;		
 			    }
		    	else
			    {
					foc="document."+form_name+"."+value1[i];
					
	                                 eval(foc).focus();
	                	                                	                                
					  return false;			
				}
				return false;
	    }
		
	}
	
return true;
}


