I want to validate an email validation of type 'abc@xyz.com.com'
Should show an error message if they enter invalid domain name.
Would be very grateful for your help.

Recommended Answers

If this is just for learning, you can also use the email input type in HTML5 which validates it. If you are doing this just through HTML4 and JavaScript look at using Regex. The example above is terrible.

http://stackoverflow.com/questions/46155/validate-email-address-in-javascript

Jump to Post

All 6 Replies

You should try matching against this expression to check if valid characters were entered for an email address:

/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/

Check out the .match() function. I don't want to completely give you the answer on this.

Should show an error message if they enter invalid domain name.

How far do you want to take this? For example, what jwmollman posted does not allow .museum. It does allow .xx which is not a valid extension (yet). I advise to fully read the second linke stbuchok provided. What about arabic domains?

Any budy know about how to perform ajax (email already exist) validation in jsp

Be a part of the DaniWeb community

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