	/* COMPANY NAME : INDICOM SOFTECH PVT. LTD.
   AUTHOR : SUCHETA , SACHIN  AND AMISH.  
            ----------------------------
   CREATED ON :  25 JUNE 2000
   DESCRIPTION : THIS FUNCTION HELPS FOR VALIDATION OF FIELDS IN HTML DOCUMENTS
                 HENCE USER DOES NOT HAVE TO WRITE VALIDATIONS ALL TIME 
				 JUST FOLLOW SIMPLE RULES GIVEN BELOW
   
   
   SPECIFICATIONS: HERE ANY NAME IN HTML TAG STARTS WITH. 
   1. "req" IT BECOMES CUMPOLSORY FIELD , NO BLANKS ALLOWED.
   2. "creq" IT BECOMES CUMPOLSORY FIELD & ALLOWS ONLY CHARACTERS , NO NUMERIC ALLOWED.
   3. "nreq" IT BECOMES CUMPOLSORY FIELD & ALLOWS ONLY NUMERICS , NO CHARACTERS ALLOWED.
   4. "mail" IF USER ENTERS IT AUTOMATICALLY CHECKS FOR CORRECT FORMAT. 
   5. "onlc" IT IS NOT CUMPOLSORY FIELD , BUT WHEN VALUE ENTERED SHOULD ONLY BE CHARACTER.
   6. "onln" IT IS NOT CUMPOLSORY FIELD , BUT WHEN VALUE ENTERED SHOULD ONLY BE NUMERIC.
   
   Note :  While calling the function add the following to your form tag

   <form name="" action="" onsubmit="return validateform(this)">
   
   Copyright 2000. Indicom Softech, INDIA.  All Rights Reserved. No part of this code should be
   changed or copied or distributed publically or used for professional purposes, without written 
   permision from Indicom Softech to do the same.
   */  





function validateform(theform)
{
 	var s=false
	var mes
	var noofelements = theform.elements.length
    var digits="0123456789"   
for (i = 0 ; i < noofelements - 1 ; i++)
{
	
	/* req for cumpolsory required field may be char or numeric */

	if(theform.elements[i].name.substring(0,3)=="req")
	{
		if(theform.elements[i].value == "")
		{
		//mes=theform.elements[i].name
		//s=true
		alert("Blank not allowed , Please enter a valid value for " + theform.elements[i].name.substring(3,20))
		theform.elements[i].focus()
		return false
	    }
	}
	
        if(theform.elements[i].name.substring(0,4)=="creq")
	    {
	     if(theform.elements[i].value == "")
	     {
	     // s=true
	    //  mes=mes+theform.elements[i].name
		 alert("Blank not allowed , Please enter a valid Character value for " + theform.elements[i].name.substring(4,20))
		  theform.elements[i].focus()
		  return false
		 }
		 else
		 {
		 var le=theform.elements[i].value.length
	//	 alert(le)
		     for(j=0;j<le;j++)
        	 {
			    if( (theform.elements[i].value.substring(j,j+1)=="0")||
			   	(theform.elements[i].value.substring(j,j+1)=="1")||
				(theform.elements[i].value.substring(j,j+1)=="2")||
				(theform.elements[i].value.substring(j,j+1)=="3")||
				(theform.elements[i].value.substring(j,j+1)=="4")||
				(theform.elements[i].value.substring(j,j+1)=="5")||
				(theform.elements[i].value.substring(j,j+1)=="6")||
				(theform.elements[i].value.substring(j,j+1)=="7")||
			 	(theform.elements[i].value.substring(j,j+1)=="8")||
		  		(theform.elements[i].value.substring(j,j+1)=="9"))
		           	{
					      alert("Please enter only character value for " + theform.elements[i].name.substring(4,20))
			              theform.elements[i].focus()
			              return false
			        } 
		      }//end of for
		 }//end of else
	}// end of creq
				
				    

	if(theform.elements[i].name.substring(0,4)=="nreq")
	{
	 if(theform.elements[i].value == "")
	 {
	// s=true
	// mes=mes+theform.elements[i].name
		alert("Blank not allowed , Please enter a valid Numeric value for " + theform.elements[i].name.substring(4,20))
	 theform.elements[i].focus()
	 return false
	 }
	 else
	 {
	 var le=theform.elements[i].value.length
	 for(j=0;j<le;j++)
      {
	   if( (theform.elements[i].value.substring(j,j+1)!="0")&&
	     (theform.elements[i].value.substring(j,j+1)!="1")&&
		 (theform.elements[i].value.substring(j,j+1)!="2")&&
		 (theform.elements[i].value.substring(j,j+1)!="3")&&
		 (theform.elements[i].value.substring(j,j+1)!="4")&&
		 (theform.elements[i].value.substring(j,j+1)!="5")&&	
		 (theform.elements[i].value.substring(j,j+1)!="6")&&
		 (theform.elements[i].value.substring(j,j+1)!="7")&&
	     (theform.elements[i].value.substring(j,j+1)!="8")&&
     	 (theform.elements[i].value.substring(j,j+1)!="9"))
			   {
			   alert("Please enter a Only Numeric value only " + theform.elements[i].name.substring(4,20))
			   theform.elements[i].focus()
			   return false
			   }//end of if
		  } //end of for
		}//end of else
	  }//end of nreq
	
			
	if(theform.elements[i].name.substring(0,4)=="mail")
      {
	      if(theform.elements[i].value=="")
          {
		  flag=2
		  }
	 else
	//	if(theform.elements[i].name.value!="")
        {
	    var le=theform.elements[i].value.length
        var flag=0
	      for(j=0;j<le;j++)
          {
	         if(theform.elements[i].value.substring(j,j+1)=="@")
	         {
	         flag=1;
	         }
          }
	     }
	}

			if (flag==0)
			{
			alert("Please enter proper email address with @ value only"+theform.elements[i].name.substring(4,20))
			theform.elements[i].focus()
			return false
			}

			// orig

// for char
var flag1=0
if(theform.elements[i].name.substring(0,4)=="onlc")
      {
	       if(theform.elements[i].value=="")
           {
		   flag1=2
		   }
	
	 else
	{    
	  var le=theform.elements[i].value.length
	 
           for(j=0;j<le;j++)
        	 {
			    if( (theform.elements[i].value.substring(j,j+1)=="0")||
			   	(theform.elements[i].value.substring(j,j+1)=="1")||
				(theform.elements[i].value.substring(j,j+1)=="2")||
				(theform.elements[i].value.substring(j,j+1)=="3")||
				(theform.elements[i].value.substring(j,j+1)=="4")||
				(theform.elements[i].value.substring(j,j+1)=="5")||
				(theform.elements[i].value.substring(j,j+1)=="6")||
				(theform.elements[i].value.substring(j,j+1)=="7")||
			 	(theform.elements[i].value.substring(j,j+1)=="8")||
		  		(theform.elements[i].value.substring(j,j+1)=="9"))
		           	{
					      alert("Please enter Only Character value for " + theform.elements[i].name.substring(4,20))
			              theform.elements[i].focus()
			              return false
			        } 
		      }//end of for
		
		     }//end for else
          }
	     
	




var flag1=0
if(theform.elements[i].name.substring(0,4)=="onln")
      {
	       if(theform.elements[i].value=="")
           {
		   flag1=2
		   }
	
	 else
	{    
	  var le=theform.elements[i].value.length
	 
           for(j=0;j<le;j++)
        	 {
			    if( (theform.elements[i].value.substring(j,j+1)!="0")&&
	     (theform.elements[i].value.substring(j,j+1)!="1")&&
		 (theform.elements[i].value.substring(j,j+1)!="2")&&
		 (theform.elements[i].value.substring(j,j+1)!="3")&&
		 (theform.elements[i].value.substring(j,j+1)!="4")&&
		 (theform.elements[i].value.substring(j,j+1)!="5")&&	
		 (theform.elements[i].value.substring(j,j+1)!="6")&&
		 (theform.elements[i].value.substring(j,j+1)!="7")&&
	     (theform.elements[i].value.substring(j,j+1)!="8")&&
     	 (theform.elements[i].value.substring(j,j+1)!="9"))
		
		           	{
					      alert("Please enter only Numeric value for " + theform.elements[i].name.substring(4,20))
			              theform.elements[i].focus()
			              return false
			        } 
		      }//end of for
		
		     }//end for else
          }
	     
		/* var d= new Date();
	if(theform.elements[i].name.substring(0,4)=="date")
{
theform.elements[i].value=d
}*/
			
	/*alert(mes)				  
						 
if(s==true)
{
alert(mes)
}*/

	                  	

}
return true}
