// JavaScript Document

function isNumberKey(evt)
		{
			 var charCode = (evt.which) ? evt.which : event.keyCode
			if (charCode > 31 && (charCode < 48 || charCode > 57))
				return false;
			else
			    return true;
	     }

function checklength(nextfield,chars,currfield) {

  x= document.form1[currfield].value.length
  if (x == chars) {
    eval('document.form1.' + nextfield + '.focus();');
  }

}


	function validate()
	{
		var flag=0;
		if((document.form1.txtName.value).length==0)
		{
			alert("Full Name ?");
			document.form1.txtName.focus();
			flag=0;
		} else if((document.form1.txtDesig.value).length==0)
		{
			alert("Designation ?");
			document.form1.txtDesig.focus();
			flag=0;
		}else if((document.form1.txtCompany.value).length==0)
		{
			alert("Company Name ?");
			document.form1.txtCompany.focus();
			flag=0;
		}else if((document.form1.txtPhone.value).length==0)
		{
			alert("Phone No. ?");
			document.form1.txtPhone.focus();
			flag=0;
		}else if((document.form1.txtEmail.value).length==0)
		{
			alert("Email Id ?");
			document.form1.txtEmail.focus();
			flag=0;
		}else if((document.form1.txtBusinessNeeds.value).length==0)
		{
			alert("Describe your Business Needs ?");
			document.form1.txtBusinessNeeds.focus();
			flag=0;
		}
		else if(ValidateForm()==false)
		{
			flag=0;
		}
		else
		{
			flag=1;
		}

		if(flag==1)
		{
			flag=0;
			return true;
			
		}
		else
		{
			return false;
		}

	}

function ValidateForm(){
	var emailID=document.form1.txtEmail

	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
 function echeck(str) {

 		var at="@"
 		var dot="."
 		var lat=str.indexOf(at)
 		var lstr=str.length
 		var ldot=str.indexOf(dot)
 		if (str.indexOf(at)==-1){
 		   alert("Invalid E-mail ID")
 		   return false
 		}

 		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
 		   alert("Invalid E-mail ID")
 		   return false
 		}

 		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
 		    alert("Invalid E-mail ID")
 		    return false
 		}

 		 if (str.indexOf(at,(lat+1))!=-1){
 		    alert("Invalid E-mail ID")
 		    return false
 		 }

 		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
 		    alert("Invalid E-mail ID")
 		    return false
 		 }

 		 if (str.indexOf(dot,(lat+2))==-1){
 		    alert("Invalid E-mail ID")
 		    return false
 		 }

 		 if (str.indexOf(" ")!=-1){
 		    alert("Invalid E-mail ID")
 		    return false
 		 }

  		 return true
	}
	
	
	
	
	