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?
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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.