Well heres the code im using, can anyone either fix this code to make it work or suggest a better way of doing this, thanks.

function ValidateForm() {
  if (document.submitform.email.value=="") {
    alert("There is no email entered!"); return false;
  }
  
  if (document.submitform.email.value=="Enter your email...") {
    alert("Please enter an email!"); return false;
  }
  
  if (document.submitform.email.str.indexOf(".") > 2) {
  	alert("Please enter a valid email"); return false;
  }
  
  if (document.submitform.email.str.indexOf("@") > 0) {
  	alert("Please enter a valid email"); return false;
  }
  
  return true;
}

sorry for the double post but heres another code i've tried which seems to be more promising, but it seems to reject everything.

var emailFilter=/^.+@.+\..{2,3}$/;
if (!(emailFilter.test(document.submitform.email))) { 
   alert("Please enter a valid email address!"); return false;
}
if(trimstr(d.emailid.value)==""){alert("Enter E-Mail ID");d.emailid.focus();return false;}
	var m = document.form1.emailid.value
	var cnt=0,spc=0,dot=0;
	for(var i=1;i<=m.length;i++)
	{
		if(m.charAt(i)=="@") cnt++;
		if(m.charAt(i)==" ") spc++;
		if(m.charAt(i)==".") dot++;
	}
	lnm=m.length
	if(cnt==0||cnt>1||spc!=0||dot==0 ||lnm<=2 )	{alert("Please Enter Valid E-mail Id ");document.form1.emailid.focus();return false;	}
commented: Thanks heaps for the email validation +1

thaks heaps! :)

Please feel free to modify this code to match your needs. If you have any question regarding this code you can document.write('Me on my inbox'). lol! Have a good day...

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Email Validation</titles>
<script type="text/javascript">
<!-- BEGIN HIDING
/* All codes are tested before release, so you are well assured that all of my codes are hustle free... 
In this basic example i will demonstrate on how to filter unnecessary characters' in your email form.
code is as follows: */
 
var validEmail = /^(\w+[\-\.])*\w+@(\w+\.)+[A-Za-z]+$/;

var validPassword = /^[A-Za-z\d]{6,8}$/;

function validate(form)
{ var email = form.Email.value;
  var password = form.Password.value;
  var errors = [];
  if ( !validEmail.test( email )) { errors[errors.length] = 'You must enter a valid email address!'; }
  if ( !validPassword.test( password )) { errors[errors.length] = 'You must enter a valid password!'; }
  if ( errors.length > 0 ) { reportErrors( errors ); return false; } return true; }

function reportErrors( errors ) 
{ var errorMessage = 'There where some problems...\n';
   for ( var x = 0; x < errors.length; x++ ) { var numberOfError = x + 1;
   errorMessage += '\n' + numberOfError + '. ' + errors[x]; } alert( errorMessage ); 
}
// DONE HIDING -->
</script>
</head>
<body>
<p>
<span><b>Login Form</b></span>
<form method="post" action="#" onsubmit="return validate( this );">
Email:<br /><input type="text" name="Email" size="25" /><br />
Password:<br /><input type="password" name="Password" size="15" /><br />
<br />
<font color="red">*</font> Password must be between 6 and 10 characters and can only contain letters and digits.<br /><br />
<input type="submit" value="Submit" />&nbsp;<input type="reset" value="Clear" />
</form>  

</p>
<!-- Hope You Had A Great Time Today! Enjoy Coding -->
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.