...

View Full Version : Email form validation



monkeys
08-03-2006, 03:40 AM
Hi,

I have a form which mostly works and validates with javascript
Name, details, email, etc.

However the email bit is happy to validate with just @. instead of a@b.net/com/whatever.

It's probably a really simple fix, but I'm still new to javascript..

Hopefully someone can point out what I need to add / change in the following section of script.


if(form.email.value=="")
{
alert("Please Enter Email Address");
return false;
}
if(form.email.value!="")
{
str=form.email.value;
var AtTheRate= str.indexOf("@");
var DotSap= str.lastIndexOf(".");
if (AtTheRate==-1 || DotSap ==-1)
{
alert("Enter Proper Email Address");
return false;
}
else
{
if( AtTheRate > DotSap )
{
alert("Enter Valid Email Address");
return false;
}
}
}


Thankyou :)

Philip M
08-03-2006, 08:00 AM
You can guess that this has been covered many times before, so you could have used the search facility.

For example:-

http://www.codingforums.com/showthread.php?t=86647



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum