1

I have read lots of questions about email validation in javascript, and never found a really satisfactory solution.

Example: Validate email address in JavaScript?

Problem is, most answers use regex, and the regex required for email is too complex to understand.

I have read that the best way to validate emails, is to use a state machine to match the spec. I can't imagine this is too complex, but can't find any examples online of non-regex email validation in javascript. Are there any out there?

Community
  • 1
  • 1
Billy Moon
  • 57,113
  • 24
  • 136
  • 237

1 Answers1

0

You should stick with ^[^@]+@[^@]+$ ..That's it..

1>Validate the mail with above regex

2>Send mail to that email address.

3>Email Id is valid if you get any response from that Id...


In case you want to prevent users from making mispells you can use mailcheck.js

enter image description here


Stop Validating Email Addresses With Complicated Regular Expressions

Highlight:

Think about it this way: I register for your website under the email address qwiufaisjdbvaadsjghb@gmail.com. C’mon. That shit’s probably going to bounce off of the illustrious mail daemon, but the formatting is fine; it’s a valid email address.

Anirudha
  • 32,393
  • 7
  • 68
  • 89