Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 5th, 2003, 07:39 AM
Registered User
Join Date: Jun 2003
Location: Trichy, TamilNadu, India.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Email Validate

How to validate given email in javascript?

Reply With Quote
  #2 (permalink)  
Old June 6th, 2003, 02:36 AM
Friend of Wrox
Join Date: Jun 2003
Location: , , USA.
Posts: 101
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Moharo

that depends on what kind of stuff you want to check in email. good start is detecting "@" and "." characters and also empty space " ". here's how you can do it:

function checkEmail(email) {
     if(email.indexOf("@")!=-1 && email.indexOf(".")!=-1 && email.indexOf(" ")!=-1) {
     alert("Specified email address is invalid");
     return false; }
     else alert("Good email address");

that should do it

the genuine genius
Reply With Quote
  #3 (permalink)  
Old June 9th, 2003, 08:33 AM
Authorized User
Join Date: Jun 2003
Location: Lexington, KY, USA.
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post

If you really want to validate an email address, you might want to use a regular expression. See http://regexlib.com/ for examples of some regular expressions that validate email addresses.

(Old dog learning new tricks...)
Reply With Quote
  #4 (permalink)  
Old July 3rd, 2003, 11:46 PM
Friend of Wrox
Points: 422, Level: 7
Points: 422, Level: 7 Points: 422, Level: 7 Points: 422, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jul 2003
Location: La Jolla, CA, USA.
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts

Here is my favorite method: (Caution: won't work if scripting is disabled!)


<title>Email Check</title>

<script language="JavaScript"><!--
function Form_Validator(theForm) {
    var regex = /^[\w\.-]+@[\w\.-]+\.[a-zA-Z]{2,3}$/
    if (!regex.test(theForm.Email.value)) {
        alert("Invalid email address.");
        return (false);
    return (true);

  <form method="POST" onsubmit="return Form_Validator(this)" action="javascript:alert('Email is valid')">
    <input name="Email" value="">
    <input type="submit" value="Validate Email">


Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
validate email address dartcoach Javascript 0 April 28th, 2008 12:58 PM
Validate multiple email addresses mat41 Javascript 1 August 29th, 2007 12:45 AM
How to validate email address crmpicco Javascript How-To 2 February 16th, 2005 10:56 AM
Validate Email address richardtr BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 6 November 23rd, 2004 01:45 PM
Email Validate nskannan2007@yahoo.com HTML Code Clinic 3 June 9th, 2003 10:49 AM

All times are GMT -4. The time now is 10:05 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.