<function validateAdd()
{
	if(fnfname()&&fnlname()&&fnemail())
		{
			//alert ("hi");
			
			document.form1.action="eventregistrationSubmit.php";
			document.form1.submit();
			return true;
		}
		return false;
}


 function fnfname()
 {
   var fname;
   fname = document.form1.fname.value;
   
   if(fname=="") 
   {
    alert("First Name Cannot Be Empty");
    document.form1.fname.focus();
    document.form1.fname.select();
    return false;      
   }
    return true;
 }
  function fnlname()
 {
   var lname;
   lname = document.form1.lname.value;
   
   if(lname=="") 
   {
    alert("Last Name Cannot Be Empty");
    document.form1.lname.focus();
    document.form1.lname.select();
    return false;      
   }
    return true;
 }
//function to check the Email

 function fnemail()
{
  
  var email;
  email = document.form1.email.value;
	
	//TO FIND A SINGLE QUOTE IN A VALUE
	var SnglQuote=email.indexOf("'");

    if (SnglQuote == "-1")
    {}
    else
    {
        alert("Please Enter a valid Email Address ");
		document.form1.email.focus();
		return false;
    }
    
		atPos = email.indexOf("@",0);
		pPos1 = email.indexOf(".",0);
		periodPos = email.indexOf(".",atPos);

	// Are there consecutive periods?
		pos1 = pPos1;
		pos2 = 0;
		
		 while (pos2 > -1) 
		  {
			pos2 = email.indexOf(".",pos1+1);
			if (pos2 == pos1+1) 
			{
			    alert("Please Enter a valid Email Address ");
				document.form1.email.focus();
				return false;
			} 
			else 
			{
				pos1 = pos2;
			}
		}

	// Is there an @ symbol in the address?

		if (atPos == -1) 
		{
		  
			alert("Please Enter a valid Email Address ");
			document.form1.email.focus();
			return false;
		}

	// Is the @ symbol in the first position?

		if (atPos == 0) 
		{
		    
			alert("Please Enter a valid Email Address ");
			document.form1.email.focus();
			return false;
		}

	// Is there a period in the first position?

		if (pPos1 == 0) 
		{
		    
			alert("Please Enter a valid Email Address ");
			document.form1.email.focus();
			return false;
		}

	// Is there more than one @ symbol in the address?

		if(email.indexOf("@",atPos+1) > -1) 
		{
		    
			alert("Please Enter a valid Email Address ");
			document.form1.email.focus();
			return false;
		}

	// Is there a period after the @ symbol?

		if (periodPos == -1) 
		{
		    
			alert("Please Enter a valid Email Address ");
			document.form1.email.focus();
			return false;
		}

	// Is the period imediately after the @ symbol?

		if (atPos+1 == periodPos) 
		{
		    
			alert("Please Enter a valid Email Address ");
			document.form1.email.focus();
			return false;
		}

	// Are there at least 2 characters after the period?

		if (periodPos+3 > email.length) 
		{
		   
			alert("Please Enter a valid Email Address");
			document.form1.email.focus();
			return false;
		}  	
	
  var emailchk;
  emailchk = document.form1.emailchk.value;
	
	//TO FIND A SINGLE QUOTE IN A VALUE
	var SnglQuote=email.indexOf("'");

    if (SnglQuote == "-1")
    {}
    else
    {
        alert("Please Enter a valid  verify Email Address ");
		document.form1.emailchk.focus();
		return false;
    }
    
		atPos = emailchk.indexOf("@",0);
		pPos1 = emailchk.indexOf(".",0);
		periodPos = emailchk.indexOf(".",atPos);

	// Are there consecutive periods?
		pos1 = pPos1;
		pos2 = 0;
		
		 while (pos2 > -1) 
		  {
			pos2 = emailchk.indexOf(".",pos1+1);
			if (pos2 == pos1+1) 
			{
			    alert("Please Enter a valid verify Email Address ");
				document.form1.emailchk.focus();
				return false;
			} 
			else 
			{
				pos1 = pos2;
			}
		}

	// Is there an @ symbol in the address?

		if (atPos == -1) 
		{
		  
			alert("Please Enter a valid verify Email Address ");
			document.form1.emailchk.focus();
			return false;
		}

	// Is the @ symbol in the first position?

		if (atPos == 0) 
		{
		    
			alert("Please Enter a valid Verify Email Address ");
			document.form1.emailchk.focus();
			return false;
		}

	// Is there a period in the first position?

		if (pPos1 == 0) 
		{
		    
			alert("Please Enter a valid Verify Email Address ");
			document.form1.emailchk.focus();
			return false;
		}

	// Is there more than one @ symbol in the address?

		if(emailchk.indexOf("@",atPos+1) > -1) 
		{
		    
			alert("Please Enter a valid Verify Email Address ");
			document.form1.emailchk.focus();
			return false;
		}

	// Is there a period after the @ symbol?

		if (periodPos == -1) 
		{
		    
			alert("Please Enter a valid Verify Email Address ");
			document.form1.emailchk.focus();
			return false;
		}

	// Is the period imediately after the @ symbol?

		if (atPos+1 == periodPos) 


		{
		    
			alert("Please Enter a valid  Verify Email Address ");
			document.form1.email.focus();
			return false;
		}

	// Are there at least 2 characters after the period?

		if (periodPos+3 > emailchk.length) 
		{
		   
			alert("Please Enter a valid Verify Email Address");
			document.form1.emailchk.focus();
			return false;
		}
	      
if(email == emailchk)
   {
    return true;
	}
	else
	{
	alert ("email and Verify Email Address must be same");
	}	 
}
 
