// JavaScript Document
<!--
function isText(str)
{
	var i=0;
	while(i<str.length)
	{
		if (str.charAt(i)>='0' && str.charAt(i)<= '9')
			return false;
		i++;
	}
	return true;
}
function isNumeric(str)
{
	var i=0;
	while(i<str.length)
	{
		if (!(str.charAt(i)>='0' && str.charAt(i)<= '9' || str.charAt(i)==' ' || str.charAt(i)=='-' || str.charAt(i)=='+') )
			return false;
		i++;
	}
	return true;
}
function trim(String)
{
   if (String == null)
   {   return ("");
   }
   return String.replace(/(^\s+)|(\s+$)/g,"");
}

function formvalidation()
{
	firstname=trim(document.form1.firstname.value);
	if (firstname=="")
	{
		alert("Enter Name");
		document.form1.firstname.focus();		
		return false;
	}
	else
		if(!isText(firstname))
		{
			alert("Check Name")
			document.form1.firstname.focus();
			return false;
		}
	

	companyname=trim(document.form1.companyname.value);
		if(!isText(companyname))
		{
			alert("Check Company name")
			document.form1.companyname.focus();
			return false;
	}
	if(companyname=="")
		companyname="N/A";	
		
	document.form1.email.value=trim(document.form1.email.value);
	email=trim(document.form1.email.value);
	if ((email==null)||(email==""))
	{
		alert("Enter E-mail")
		document.form1.email.focus()
		return false;
	}
	if (isMailid(email)==false)
	{
		document.form1.email.focus()
		return false;
	}


	phone=trim(document.form1.phone.value);
	if(phone=="")
	{
		alert("Enter Phone")
		document.form1.phone.focus()
		return false;
	}	
	else if(!(isNumeric(phone))&& phone!="")	
	{		
		alert("Check Phone")
		document.form1.phone.focus()
		return false;
	}
	
		
	address1=trim(document.form1.address1.value)
	if(address1=="")
		address1="N/A";
		
	city=trim(document.form1.city.value);
	if(city=="")
	{
		alert("Enter City")
		document.form1.city.focus()
		return false;
	}
	else if(isNumeric(city)&& city!="")	
	{		
		alert("Check City")
		document.form1.city.focus()
		return false;
	}
	
	country=trim(document.form1.reg_ca_country.value);
	if(country=="select")
	{	
		alert("Select Country")
		document.form1.reg_ca_country.focus()
		return  false;
	}
		
	zip=trim(document.form1.zip.value);
	if(zip=="")
		zip="N/A";
		
	cust_msg=trim(document.form1.cust_msg.value)
	if(cust_msg=="")
	{
		alert("Enter Message")
		document.form1.cust_msg.focus()
		return false;
	}
	
    var CurrentDate = new Date();

	return true;
}
  
  // Check the E-Mail Id
function isMailid(str) 
{
	var emailPat = /^[\w-\.]+\@[\w\.-]+\.[a-z]{2,4}$/;
	var matchArray = str.match(emailPat);
		if (matchArray == null)
		{
		alert("Invalid E-mail");
		return false;
		}
}

function formvalidation1()
{

	//First name check
	firstname=trim(document.form1.firstname.value);
	if (firstname=="")
	{
		alert("Enter First name");
		document.form1.firstname.focus();		
		return false;
	}
	else
		if(!isText(firstname))
		{
			alert("Check First name")
			document.form1.firstname.focus();
			return false;
		}
	//Position check	
	position=trim(document.form1.position.value);
	if (position=="")
	{
		alert("Enter Position");
		document.form1.position.focus();		
		return false;
	}
	else
		if(!isText(position))
		{
			alert("Check Position")
			document.form1.position.focus();
			return false;
		}
	
	//Email check	
	document.form1.email.value=trim(document.form1.email.value);
	email=trim(document.form1.email.value);
	if ((email==null)||(email==""))
	{
		alert("Enter E-mail")
		document.form1.email.focus()
		return false;
	}
	if (isMailid(email)==false)
	{
		document.form1.email.focus()
		return false;
	}

//Mobile check	
	mobile=trim(document.form1.mobile.value);
	if(mobile=="")
	{
		alert("Enter Mobile no")
		document.form1.mobile.focus()
		return false;
	}	
	else if(!(isNumeric(mobile))&& mobile!="")	
	{		
		alert("Check Mobile no")
		document.form1.mobile.focus()
		return false;
	}
//Organization check	
	organization=trim(document.form1.organization.value);
	if (organization=="")
	{
		alert("Enter Organization name");
		document.form1.organization.focus();		
		return false;
	}
	else
		if(!isText(organization))
		{
			alert("Check Organization name")
			document.form1.organization.focus();
			return false;
		}
//Address check		
	address=trim(document.form1.address.value);
	if (address=="")
	{
		alert("Enter Address");
		document.form1.address.focus();		
		return false;
	}
//Contact check
	contact=trim(document.form1.contact.value);
	if(contact=="")
	{
		alert("Enter Business contact")
		document.form1.contact.focus()
		return false;
	}	
	else if(!(isNumeric(contact))&& contact!="")	
	{		
		alert("Check Business contact")
		document.form1.contact.focus()
		return false;
	}

	extn=document.form1.extn.value;
	if(!(isNumeric(extn))&& extn!="")	
	{		
		alert("Check Extension")
		document.form1.extn.focus()
		return false;
	}
    var CurrentDate = new Date();

	return true;
}
