Hi everyone hope all well.

I need your expertise. I have a problem with the email part of this javascript. Everything is working fine except for It will not validate when i add a period (.) before the @ sign. I am wanting to be able to put in an email like this

abc.def@gmail.com

or

abc+def@gmail.com

Here is the code for you to look at

Code:
<script type="text/javascript">
function validate_form() {

    if (!ValidatePhoneNumber(document.second.HomePhone.value)) {
        return false;
    }
	if(!ValidateZip(document.second.ZipCode.value))
	{
			return false;
	}
    if ( document.second.degreeLevel.selectedIndex == 0 )
    {
        alert ( "Please select degree level" );
        return false;
    }
	if ( document.second.ProgramInterest.selectedIndex == 0 )
    {
        alert ( "Please select area of study" );
        return false;
    }
	if ( document.second.LevelofEducationCompleted.selectedIndex == 0 )
    {
        alert ( "Please select level of education" );
        return false;
    }

	 if ( document.second.FirstName.value == '' )
    {
        alert ( "Please Enter a First Name" );
        return false;
    }

	 if ( document.second.LastName.value == '' )
    {
        alert ( "Please Enter a Last Name" );
        return false;
    }

	 if ( document.second.Address.value == '' )
    {
        alert ( "Please Enter a Address" );
        return false;
    }

	 if ( document.second.City.value == '' )
    {
        alert ( "Please Enter a City" );
        return false;
    }

	 if ( document.second.State.selectedIndex == 0 )
    {
        alert ( "Please Select a State" );
        return false;
    }
	if(!ValidateName(document.second.FirstName.value))
	{
		return false;
	}
	if(!ValidateName(document.second.LastName.value))
		{
			return false;
	}

	
	function ValidatePhoneNumber(field) {
	    var valid = "0123456789";
	    var hyphencount = 0;
	    if (field.length != 10) {
	        alert("Please enter your 10 digits phone.");
	        return false;
	    }
	    for (var i = 0; i < field.length; i++) {
	        temp = "" + field.substring(i, i + 1);
	        if (valid.indexOf(temp) == "-1") {
	            alert("Invalid characters in your phone.  Please try again.");
	            return false;
	        }

	    }
	    return true;    
	}  

    
      
    if(!EmailValid(document.second.Email.value))
    {
    	return false;
    }
    function ValidateZip(field) {
		var valid = "0123456789";
		var hyphencount = 0;
		if (field.length!=5 ) {
			alert("Please enter your 5 digit zip code.");
			return false;
		}
		for (var i=0; i < field.length; i++) {
			temp = "" + field.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") {
				alert("Invalid characters in your zip code.  Please try again.");
				return false;
			}

		}

	return true;
	}
	function ValidateName(field)
	{
		var invalid="0123456789()-+=@#$%^&*!~`{}][|:;<>,?/";
		for (var i=0; i < field.length; i++) {
			temp = "" + field.substring(i, i+1);
			if (invalid.indexOf(temp) != "-1") {
				alert("Invalid characters in your name field.  Please try again.");
				return false;
			}

		}
		return true;
	}
   function EmailValid(email)
   	{
   		if(email=="")
   		{
   			alert("Email is required field!")
   			return false
   		}
   		len = email.length

   		if((email.charAt(1)=='.')||(email.charAt(1)=='@')||(email.charAt(1)=='.'))
   		{
			alert("Invalid Email Please try again!")
			return false
   		}
   		if((email.charAt(len-2)=='@')||(email.charAt(len-2)=='.'))
   		{
			alert("Invalid Email Please try again!")
			return false
   		}



   		count=0
   		dotcount=0
		for (i=0; i< email.length; i++)
			{
				if(email.charAt(i)=='@')
				count++
				if(email.charAt(i)=='.')
				dotcount++
   		 	}

		 if((count !=1)||(dotcount !=1))
			{
			alert("Invalid Email Please try again!")
			return false
			}


   	return true
	}

}
</script>
Im sure it is something small. i have tried changing things around but it will not work for me.

Any help would be great.

Thanks everyone

Nim