Last active
February 23, 2022 21:46
-
-
Save artulloss/c16cce8f7353eac34268a2310d6a9e60 to your computer and use it in GitHub Desktop.
Email Regex Javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is the same checks as the HTML5 email input form field as outlined in the link below. | |
// Email regex | |
/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/ | |
function isEmail(email) { | |
// https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address | |
const regex = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; | |
return regex.test(email) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment