Timeline for How can I validate an email address in JavaScript?
Current License: CC BY-SA 4.0
24 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 5, 2022 at 14:54 | history | edited | Regular Jo | CC BY-SA 4.0 |
One regex used anchors while the other did not, without explanation. Edited for consistency and explanation
|
Aug 21, 2022 at 11:03 | comment | added | Jelaby |
@Timo [^\s@] means "neither a whitespace character nor @ ". [xyz] means any one of x, y or z, and [^xyz] means any one character except x, y or z. \s means "any whitespace character". \S means "any character that is not whitespace".
|
|
Jul 24, 2022 at 11:35 | comment | added | Timo |
2 issues: Is [^\s@] no string followed by @ ? Why do you use \s and \S ? Is it related to whitespaces?
|
|
Feb 10, 2022 at 9:42 | comment | added | ruohola |
@JoseG. Yes. E.g. http://ai is someone's valid domain, so they could use e.g. a@ai as their email.
|
|
Feb 10, 2022 at 9:10 | comment | added | PG20 | @ruohola is this also the reason why an email will be valid after you input an @ sign without having any periods after? | |
Oct 6, 2021 at 14:08 | comment | added | ruohola |
Emails can contain multiple @ signs (as comments), also an email doesn't have to contain a period.
|
|
Jul 29, 2021 at 15:50 | history | edited | Akaisteph7 | CC BY-SA 4.0 |
fix regex
|
Jul 15, 2021 at 13:00 | comment | added | waldgeist |
The second regexp does not require a top-level domain, i.e. it accepts user@domain . But AFAIK this is actually a valid e-mail address, although uncommon. The first regexp requires a TLD, so it doesn't cover these types of addresses.
|
|
Feb 22, 2021 at 21:55 | history | edited | Nick Bull | CC BY-SA 4.0 |
added 74 characters in body
|
Jun 20, 2020 at 0:55 | review | Suggested edits | |||
Jun 20, 2020 at 15:01 | |||||
Mar 14, 2020 at 6:40 | history | edited | the-breaker | CC BY-SA 4.0 |
just made the code executable and add a link
|
Jan 4, 2020 at 23:32 | review | Suggested edits | |||
Jan 5, 2020 at 0:32 | |||||
Dec 30, 2019 at 23:19 | history | edited | the Tin Man | CC BY-SA 4.0 |
edited for readability
|
Aug 14, 2018 at 23:30 | history | rollback | C. Lee |
Rollback to Revision 6
|
|
Apr 12, 2018 at 3:28 | history | edited | tk_ | CC BY-SA 3.0 |
added 10 characters in body
|
Nov 12, 2015 at 21:23 | history | rollback | C. Lee |
Rollback to Revision 4 - Roll back to revision 2
|
|
Nov 3, 2015 at 22:12 | history | edited | André Chalella | CC BY-SA 3.0 |
Modified regex in accordance with what the author agreed to, plus clarifications.
|
Nov 26, 2014 at 10:35 | history | rollback | Flexo♦ |
Rollback to Revision 2
|
|
Nov 20, 2014 at 9:28 | history | edited | Robin C Samuel | CC BY-SA 3.0 |
udpated regexp
|
Sep 11, 2013 at 2:21 | history | made wiki | Post Made Community Wiki by pera | ||
Aug 24, 2013 at 20:44 | history | edited | Peter Mortensen | CC BY-SA 3.0 |
Copy edited. Removed meta information (this belongs in comments, if any).
|
Aug 9, 2012 at 14:58 | comment | added | OregonTrail |
@ImmortalFirefly, the regex you provided will actually match name@[email protected] . Try pasting your line into a JavaScript console. I believe your intention was to match only the entire text, which would require the beginning of text '^' and end of text '$' operators. The one I'm using is /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test('name@[email protected]')
|
|
Jul 30, 2012 at 18:20 | comment | added | user83358 | You can implement something 20x as long that might cause problems for a few users and might not be valid in the future, or you can grab ImmortalFirefly's version to make sure they at least put in the effort to make it look real. Depending on your application it may be more likely to come across someone will get mad because you don't accept their unconventional email, rather than someone who causes problems by entering email addresses that don't really exist (which they can do anyways by entering a 100% valid RFC2822 email address but using an unregistered username or domain). Upvoted! | |
Feb 9, 2012 at 2:22 | history | answered | C. Lee | CC BY-SA 3.0 |