Created
April 2, 2019 17:37
-
-
Save fasidOnGit/0fbfa1c6dc0c97981f62a4167347b68d to your computer and use it in GitHub Desktop.
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
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