function trim(str)
{
   return str.replace(/^\s+|\s+$/g,'');
}
function Validate(){

	var email=document.frm.email.value;

	if(email==''){

		alert('Please Enter your Email');

		document.frm.email.focus();

		return false;

	}

	if(email!=''){

	   if(emailcheck(email)==false)

	   {

	   	  document.frm.email.value='';	

	      document.frm.email.focus();

		  return false;

		}  	   

	}
	document.frm.action = 'forgotpassword.php';
	document.frm.submit();

}

function echeck(str) {

if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(str))

{

alert("Invalid Email");

return false;

}

}
function emailcheck(str) 

{

if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(trim(str)))

//if((str.indexOf('@')<0) ||(str.indexOf('@')!=-1) && (str.charAt(str.length-4)!='.') && (str.charAt(str.length-3)!='.') && str.charAt(0)=='@'))

{

alert("Please enter a valid email address eg: username@domainname.com");

return false;

}

}
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->