﻿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					
	}

function ValidateForm()
{
	var emailID=document.getElementById("ctl00_smeconnectdata_txtEmail")
	var Name=document.getElementById("ctl00_smeconnectdata_txtName")
	var Phone=document.getElementById("ctl00_smeconnectdata_txtPhone")
	var Company=document.getElementById("ctl00_smeconnectdata_txtCompany")
	var Position=document.getElementById("ctl00_smeconnectdata_txtPosition")
	var Comments=document.getElementById("ctl00_smeconnectdata_txtComments")
	
	 var digits="0123456789";
     var temp;
	
	if ((Name.value==null)||(Name.value==""))
	{
		alert("Please Enter Name")
		// document.getElementById("txtName").focus()
		 Name.focus()
		return false
	}	
	if ((emailID.value==null)||(emailID.value==""))
	{
		alert("Please Enter your Email ID")
		 document.getElementById("ctl00_smeconnectdata_txtEmail").focus()
		return false		
	}
	if (echeck(emailID.value)==false)
	{
		emailID.value=""
		 document.getElementById("ctl00_smeconnectdata_txtEmail").focus()
		return false
	}	
	if ((Phone.value==null)||(Phone.value==""))
	{
		alert("Please Enter Phone Number")
		document.getElementById("ctl00_smeconnectdata_txtPhone").focus()
		return false
	}
	else
	{
	     for (var i=0;i<document.getElementById("ctl00_smeconnectdata_txtPhone").value.length;i++)
             {
               temp=document.getElementById("ctl00_smeconnectdata_txtPhone").value.substring(i,i+1);
               if (digits.indexOf(temp)==-1)
               {
                        alert("Please enter correct Phone Number");
                        Phone.focus();
                        return false;
               }
              }
	}
		
	if ((Company.value==null)||(Company.value==""))
	{
		alert("Please Enter Comapany Name")
		 document.getElementById("ctl00_smeconnectdata_txtCompany").focus()
		return false
	}
	if ((Position.value==null)||(Position.value==""))
	{
		alert("Please Enter Position")
		 document.getElementById("ctl00_smeconnectdata_txtPosition").focus();
		return false
	}
	if ((Comments.value==null)||(Comments.value==""))
	{
		alert("Please Enter Comments")
		 document.getElementById("ctl00_smeconnectdata_txtComments").focus();
		return false
	}	
	return true
 }
