Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fasidOnGit/0fbfa1c6dc0c97981f62a4167347b68d to your computer and use it in GitHub Desktop.
Save fasidOnGit/0fbfa1c6dc0c97981f62a4167347b68d to your computer and use it in GitHub Desktop.
function email(email) {
if(typeof email !== "undefined"){
let lastAtPos = email.lastIndexOf('@');
let lastDotPos = email.lastIndexOf('.');
if (!(lastAtPos < lastDotPos && lastAtPos > 0 && email.indexOf('@@') == -1 && lastDotPos > 2 && (email.length - lastDotPos) > 2)) {
formIsValid = false;
return console.log("Email is not valid");
}
return console.log('valid')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment