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 :)
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 :)