I am trying to validate email using regex the problem is it fails to validate the email that doesn't have @ character or have have @ character by the end of the word like if i type abcd that would fail also abcd@ it would fail too. this is the regex i am using and i couldn't find anything that cover those cases the abcd and the abcd@
let emailRegex = /^(([^<>()[\]\\.,;:\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,}))$/;
Try this regex snippet:
^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$
should invalidates cases like:
@gmail.com / asdf@gmail.com@
validates
asdf@gmail.com