function Trim(str)
{ 
 lenstr = str.length
 substr = str
 for (i=0;i<lenstr;i++)
 {
	c = str.charAt(i);	
	if(c == ' ' || c == '\n'  || c == '\r')
		substr = str.substring(i+1,str.length)
	else
		break   
 }

 lenstr = substr.length
 str = substr 
 //alert(lenstr);
 for(i=(lenstr)-1;i>=0;i--)
 {
	c = str.charAt(i);
	//alert("hello")
	if (c == ' ' || c == '\n' || c == '\r')
	{
		substr = str.substring(0,i);		
	}
	else
	{
		break;
	}
 } 
 return substr	
}


function isEMail(str)
  {
	lenstr = Trim(str).length;
	nAtr = str.indexOf("@");
	nDot = str.indexOf(".",nAtr);
	nAtr2 = str.indexOf("@",nAtr+1);
	nfDot = str.indexOf(".");
	nlDot = str.indexOf(".",lenstr-1);
	nDDot = str.indexOf("..");

	if (lenstr>4 &&  nAtr>0 && nDot>(nAtr+1) && nAtr2==-1 && nDot<lenstr-1 && nfDot>0 && nlDot==-1 && nDDot==-1)
		return true;
	else
		return false;
	return true ;
  }
  
  
function Form1_Validator()
{
  if (Trim(document.Form1.FirstName.value) == "")
  {
	document.Form1.FirstName.value = Trim(document.Form1.FirstName.value);
    alert("Please enter a value for the \"First Name\" field.");
    document.Form1.FirstName.focus();
    return (false);
  }

  if (document.Form1.FirstName.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"First Name\" field.");
    document.Form1.FirstName.focus();
    return (false);
  }

  if (document.Form1.FirstName.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"First Name\" field.");
    document.Form1.FirstName.focus();
    return (false);
  }
  if (Trim(document.Form1.LastName.value) == "")
  {
    alert("Please enter a value for the \"Last Name\" field.");
    document.Form1.LastName.value = Trim(document.Form1.LastName.value);
    document.Form1.LastName.focus();
    return (false);
  }

  if (document.Form1.LastName.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Last Name\" field.");
    document.Form1.LastName.focus();
    return (false);
  }

  if (document.Form1.LastName.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Last Name\" field.");
    document.Form1.LastName.focus();
    return (false);
  }
  
  if (Trim(document.Form1.design.value) == "")
  {
    alert("Please enter a value for the \"Designation\" field.");
    document.Form1.design.value = Trim(document.Form1.design.value);
    document.Form1.design.focus();
    return (false);
  }

  if (document.Form1.design.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Designation\" field.");
    document.Form1.design.focus();
    return (false);
  }

  if (document.Form1.design.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"Designation\" field.");
    document.Form1.design.focus();
    return (false);
  }

if (Trim(document.Form1.comp.value) == "")
  {
    alert("Please enter a value for the \"Company Name\" field.");
    document.Form1.comp.value = Trim(document.Form1.comp.value);
    document.Form1.comp.focus();
    return (false);
  }

  if (document.Form1.comp.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Company Name\" field.");
    document.Form1.comp.focus();
    return (false);
  }

  if (document.Form1.comp.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"Company Name\" field.");
    document.Form1.comp.focus();
    return (false);
  }
  if (Trim(document.Form1.email.value) == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    document.Form1.email.value = Trim(document.Form1.email.value);
    document.Form1.email.focus();
    return (false);
  }  
  
  if (isEMail(document.Form1.email.value)==false)
  {
	alert("Please enter valid value for \"Email\" .")
	document.Form1.email.focus();
	return false;
  }
   

	/*nExit = "nop"
	sValue = document.Form1.email.value
	for(k=0;k<sValue.length;k++)
		{
		if(sValue.charAt(k) == "@" && "." )
			{
			nExit = "yes"
			break;
			}
		}
		if(nExit != "yes")
			{
			alert("Please use \"@\" or \".\" \n in value for the \"Email\" field")
			document.Form1.email.focus();
			return false;
			}
	*/


  if (document.Form1.email.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Email\" field.");
    document.Form1.email.focus();
    return (false);
  }

  if (document.Form1.email.value.length > 200)
  {
    alert("Please enter at most 200 characters in the \"Email\" field.");
    document.Form1.email.focus();
    return (false);
  }
  if (Trim(document.Form1.add1.value) == "")
  {
    alert("Please enter a value for the \"Address1\" field.");
    document.Form1.add1.value = Trim(document.Form1.add1.value);
    document.Form1.add1.focus();
    return (false);
  }

  if (document.Form1.add1.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Address1\" field.");
    document.Form1.add1.focus();
    return (false);
  }

  if (document.Form1.add1.value.length > 1000)
  {
    alert("Please enter at most 1000 characters in the \"Address1\" field.");
    document.Form1.add1.focus();
    return (false);  
  }
  if (document.Form1.add2.value.length > 1000)
  {
    alert("Please enter at most 1000 characters in the \"Address2\" field.");
    document.Form1.add2.focus();
    return (false);  
  }
  
  if (Trim(document.Form1.ct.value) == "")
  {
    alert("Please enter a value for the \"City\" field.");
    document.Form1.ct.value = Trim(document.Form1.ct.value);
    document.Form1.ct.focus();
    return (false);
  }

  if (document.Form1.ct.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"City\" field.");
    document.Form1.ct.focus();
    return (false);
  }

  if (document.Form1.ct.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"City\" field.");
    document.Form1.ct.focus();
    return (false);
  }
  
  if (document.Form1.StateOrProvince.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"State/Province\" field.");
    document.Form1.StateOrProvince.focus();
    return (false);
  }
  
  if (Trim(document.Form1.ZipOrPostalcode.value) == "")
  {
    alert("Please enter a value for the \"Zip/Postalcode\" field.");
    document.Form1.ZipOrPostalcode.value = Trim(document.Form1.ZipOrPostalcode.value);
    document.Form1.ZipOrPostalcode.focus();
    return (false);
  }
  /*if (isNaN(document.Form1.ZipOrPostalcode.value))
  {
	alert("Pleasde enter numeric value for ZipOrPostalcode.");
	document.Form1.ZipOrPostalcode.focus();
	return false;
  }*/
  if (document.Form1.ZipOrPostalcode.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Zip/Postalcode\" field.");
    document.Form1.ZipOrPostalcode.focus();
    return (false);
  }

  if (Trim(document.Form1.ZipOrPostalcode.value).length > 50)
  {
    alert("Please enter at most 50 characters in the \"Zip/Postalcode\" field.");
    document.Form1.ZipOrPostalcode.focus();
    return (false);
  }
  
  if (document.Form1.country.selectedIndex < 0)
  {
    alert("Please select one of the \"Country\" options.");
    document.Form1.country.focus();
    return (false);
  }

  if (document.Form1.country.selectedIndex == 0)
  {
    alert("The first \"Country\" option is not a valid selection.  Please choose one of the other options.");
    document.Form1.country.focus();
    return (false);
  }
  if (Trim(document.Form1.tp.value) == "")
  {
    alert("Please enter a value for the \"Telephone\" field.");
    document.Form1.tp.value = Trim(document.Form1.tp.value);
    document.Form1.tp.focus();
    return (false);
  } 
  if (document.Form1.tp.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Telephone\" field.");
    document.Form1.tp.focus();
    return (false);
  }

  if (document.Form1.tp.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Telephone\" field.");
    document.Form1.tp.focus();
    return (false);
  }
  if (document.Form1.phone.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Fax\" field.");
    document.Form1.phone.focus();
    return (false);
  }
  
  if (Trim(document.Form1.message.value) == "")
  {
    alert("Please enter a value for the \"Message\" field.");
    document.Form1.message.value = Trim(document.Form1.message.value);
    document.Form1.message.focus();
    return (false);
  }

  if (document.Form1.message.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Message\" field.");
    document.Form1.message.focus();
    return (false);
  }

  if (document.Form1.message.value.length > 1000)
  {
    alert("Please enter at most 1000 characters in the \"Message\" field.");
    document.Form1.message.focus();
    return (false);
  }
  return (true);
}
<!----- contactus --->
function Form2_Validator()
{  
  if (Trim(document.Form2.FirstName.value) == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    document.Form2.FirstName.value = Trim(document.Form2.FirstName.value);
    document.Form2.FirstName.focus();
    return (false);
  }

  if (document.Form2.FirstName.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"First Name\" field.");
    document.Form2.FirstName.focus();
    return (false);
  }

  if (document.Form2.FirstName.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"First Name\" field.");
    document.Form2.FirstName.focus();
    return (false);
  }
  if (Trim(document.Form2.LastName.value) == "")
  {
    alert("Please enter a value for the \"Last Name\" field.");
    document.Form2.LastName.value = Trim(document.Form2.LastName.value);
    document.Form2.LastName.focus();
    return (false);
  }

  if (document.Form2.LastName.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Last Name\" field.");
    document.Form2.LastName.focus();
    return (false);
  }

  if (document.Form2.LastName.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Last Name\" field.");
    document.Form2.LastName.focus();
    return (false);
  }
  if (document.Form2.design.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"Designation\" field.");
    document.Form2.design.focus();
    return (false);
  }
  if (document.Form2.comp.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"Company Name\" field.");
    document.Form2.comp.focus();
    return (false);
  }
  if (Trim(document.Form2.email.value) == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    document.Form2.email.value = Trim(document.Form2.email.value);
    document.Form2.email.focus();
    return (false);
  }
  
  if (isEMail(document.Form2.email.value)==false)
  {
	alert("Please enter valid value for \"Email\" .")
	document.Form2.email.focus();
	return false;
  }

	/*nExit = "nop"
	sValue = document.Form2.email.value
	for(k=0;k<sValue.length;k++)
		{
		if(sValue.charAt(k) == "@" && "." )
			{
			nExit = "yes"
			break;
			}
		}
		if(nExit != "yes")
			{
			alert("Please use \"@\" or \".\" \n in value for the \"Email\" field")
			document.Form2.email.focus();
			return false;
			}
	*/

  if (document.Form2.email.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Email\" field.");
    document.Form2.email.focus();
    return (false);
  }

  if (document.Form2.email.value.length > 200)
  {
    alert("Please enter at most 200 characters in the \"Email\" field.");
    document.Form2.email.focus();
    return (false);
  }
  if (document.Form2.add1.value.length > 1000)
  {
    alert("Please enter at most 1000 characters in the \"Address1\" field.");
    document.Form2.add1.focus();
    return (false);  
  }
  if (document.Form2.add2.value.length > 1000)
  {
    alert("Please enter at most 1000 characters in the \"Address2\" field.");
    document.Form2.add2.focus();
    return (false);
  }
  if (document.Form2.city.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"City\" field.");
    document.Form2.city.focus();
    return (false);
  }
  if (document.Form2.StateOrProvince.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"State/Province\" field.");
    document.Form2.StateOrProvince.focus();
    return (false);
  }
  if (document.Form2.ZipOrPostalcode.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Zip/Postalcode\" field.");
    document.Form2.ZipOrPostalcode.focus();
    return (false);
  }
  if (document.Form2.country.selectedIndex < 0)
  {
    alert("Please select one of the \"Country\" options.");
    document.Form2.country.focus();
    return (false);
  }

  if (document.Form2.country.selectedIndex == 0)
  {
    alert("The first \"Country\" option is not a valid selection.  Please choose one of the other options.");
    document.Form2.country.focus();
    return (false);
  }
  if (document.Form2.tp.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Telephone\" field.");
    document.Form2.tp.focus();
    return (false);
  }
  if (document.Form2.phone.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Fax\" field.");
    document.Form2.phone.focus();
    return (false);
  }
  if (Trim(document.Form2.message.value) == "")
  {
    alert("Please enter a value for the \"Message\" field.");
    document.Form2.message.value = Trim(document.Form2.message.value);
    document.Form2.message.focus();
    return (false);
  }

  if (document.Form2.message.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Message\" field.");
    document.Form2.message.focus();
    return (false);
  }

  if (document.Form2.message.value.length > 1000)
  {
    alert("Please enter at most 1000 characters in the \"Message\" field.");
    document.Form2.message.focus();
    return (false);
  }
  return (true);
}

function validate(field) {
/*
var valid = "-0123456789"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Invalid entry! Only numbers are accepted!");
field.focus();
field.select();
  }
*/
}

<!----- download form --->

function form3_Validator()
{  
  if (Trim(document.form3.FirstName.value) == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    document.form3.FirstName.value = Trim(document.form3.FirstName.value);
    document.form3.FirstName.focus();
    return (false);
  }

  if (document.form3.FirstName.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"First Name\" field.");
    document.form3.FirstName.focus();
    return (false);
  }
 /* 
  if (Trim(document.form3.LastName.value) == "")
  {
    alert("Please enter a value for the \"Last Name\" field.");
    document.form3.LastName.value = Trim(document.form3.LastName.value);
    document.form3.LastName.focus();
    return (false);
  }

  if (document.form3.LastName.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"Last Name\" field.");
    document.form3.LastName.focus();
    return (false);
  }
  */
  if (Trim(document.form3.email.value) == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    document.form3.email.value = Trim(document.form3.email.value);
    document.form3.email.focus();
    return (false);
  }
	
  if (isEMail(document.form3.email.value)==false)
  {
	alert("Please enter valid value for \"Email\" .")
	document.form3.email.focus();
	return false;
  }
  	
	/*nExit = "nop"
	sValue = document.form3.email.value
	for(k=0;k<sValue.length;k++)
		{
		if(sValue.charAt(k) == "@" && "." )
			{
			nExit = "yes"
			break;
			}
		}
		if(nExit != "yes")
			{
			alert("Please use \"@\" or \".\" \n in value for the \"Email\" field")
			document.form3.email.focus();
			return false;
			}
		*/

  if (document.form3.email.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"Email\" field.");
    document.form3.email.focus();
    return (false);
  }
  if (Trim(document.form3.remail.value) == "")
  {
    alert("Please enter a value for the \"Retype Email\" field.");
    document.form3.remail.value = Trim(document.form3.remail.value);
    document.form3.remail.focus();
    return (false);
  }
  if (isEMail(document.form3.remail.value)==false)
  {
	alert("Please enter valid value for \"Email\" .")
	document.form3.remail.focus();
	return false;
  }
  
	/*nExit = "nop"
	sValue = document.form3.remail.value
	for(k=0;k<sValue.length;k++)
		{
		if(sValue.charAt(k) == "@" && "." )
			{
			nExit = "yes"
			break;
			}
		}
		if(nExit != "yes")
			{
			alert("Please use \"@\" or \".\" \n in value for the \"Retype Email\" field")
			document.form3.remail.focus();
			return false;
			}
		*/

  if (document.form3.remail.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"Retype Email\" field.");
    document.form3.remail.focus();
    return (false);
  }
  
  semail=Trim(document.form3.email.value);
  //alert(semail+"::");
  sremail=Trim(document.form3.remail.value);
  //alert(sremail+"::");  
  if(Trim(document.form3.email.value) != Trim(document.form3.remail.value))
  {
  	alert("Please enter the same Email-address and Retype Email-address.");
    document.form3.email.focus();
    return (false);
  }
  
  if (document.form3.comp.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"Company Name\" field.");
    document.form3.comp.focus();
    return (false);
  }

  if (document.form3.country.selectedIndex == 0)
  {
    alert("The first \"Country\" option is not a valid selection.  Please choose one of the other options.");
    document.form3.country.focus();
    return (false);
  }
  
  if (document.form3.tp.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Telephone\" field.");
    document.form3.tp.focus();
    return (false);
  }
  if (document.form3.message.value.length > 1000)
  {
    alert("Please enter at most 1000 characters in the \"Message\" field.");
    document.form3.message.focus();
    return (false);
  }
  return (true);
}

