Skip to content

Instantly share code, notes, and snippets.

@jgphilpott
Last active November 18, 2022 11:40
Show Gist options
  • Save jgphilpott/a1ffedea1d1a70320b8075597df1943a to your computer and use it in GitHub Desktop.
Save jgphilpott/a1ffedea1d1a70320b8075597df1943a to your computer and use it in GitHub Desktop.
A simple JS function for checking if an Email is valid.
# Credit: https://stackoverflow.com/a/46181/1544937
validEmail = (email = "@") ->
return /^(([^<>()\[\]\\.,;:\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,}))$/.test String(email).toLowerCase()
// Generated by CoffeeScript 2.7.0
// Credit: https://stackoverflow.com/a/46181/1544937
var validEmail;
validEmail = function(email = "@") {
return /^(([^<>()\[\]\\.,;:\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,}))$/.test(String(email).toLowerCase());
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment