DEV Community

Discussion on: How to validate an email address in JavaScript

Collapse
berslucas profile image
Lucas Bersier

You could also use <input type="email"> if you're targeting not-edge.

I always jump to the RFC-5322 standard regex (emailregex.com/), but the above seems smaller and less complicated for most projects that don't need to 100% cover all cases.

/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
Collapse
seraphicrav profile image
Ravaka Razafimanantsoa

This regular expression does not validate the new top level domains such as https://はじめよう.みんな/index.html

Collapse
mogery profile image
Gergő Móricz

You can use u at the end to do unicode validation too IIRC.