simple regex for email address validation
-
26-10-2019 - |
Question
I need a regex to exclude certain characters such as 'ç' and also to check '@' sign is present. Can someone help?
I am using jquery to do client-side validation using the following expression:
(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[\w-]{2,4}$/)
Solution
Chiefly:
function isAValidEmailAddress(emailAddress){
return /^[a-z0-9_\-\.]{2,}@[a-z0-9_\-\.]{2,}\.[a-z]{2,}$/i.test(emailAddress);
}
Use http://en.wikipedia.org/wiki/Email_address#Syntax for a better regular expression.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow