Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

email validation in checking for ".com" string

Status
Not open for further replies.

peach255

Programmer
Joined
Jan 20, 2003
Messages
29
Location
US
I have the following code that is giving me an error when I tried to add the piece on making sure the email has ".com" at the end. Otherwise, when I take out that piece of the code on checking for the string ".com", it works.
My code is as follow:
checkEmail = form.manemail.value

if ( (InStr(1,manemail,&quot;.com&quot;,vbTextCompare) = 0) || (checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.')))
{alert(&quot;You have entered an invalid email address. Please try again.&quot;);
form.manemail.select();
return false;
}
.........

The field is called &quot;manemail&quot;. Thanks!
 
try this one out for validating your emails
_______________________________________________
{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }

_______________________________________________
for the best results to your questions: FAQ333-2924
Is your question a
 
Just a word....

you should also be testing for .net, .org, .biz. etc! There's always a better way...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top