Skip to content

Instantly share code, notes, and snippets.

@waqas385
Last active March 7, 2018 05:53
Show Gist options
  • Save waqas385/4a0521f05015c4af1660103e60424fbb to your computer and use it in GitHub Desktop.
Save waqas385/4a0521f05015c4af1660103e60424fbb to your computer and use it in GitHub Desktop.
Simple regular expression to validate email using JS
/^\w+@[a-zA-Z]+\.(com|org|net)$/.test("foo@bar.com")
/*
* It will validate email of following pattern
* 1- Starting with any word
* 2- Must contains @
* 3- Must contains characters a-z & A-z after @
* 4- Must contains .
* 5- Ends with either (com, org or net)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment