I'm currently using below regex to check emails,
\w+@\w+\.\w+
but I would like to force the user to use their school domain (mark@college.edu), how do I accomplish this?
I'm currently using below regex to check emails,
\w+@\w+\.\w+
but I would like to force the user to use their school domain (mark@college.edu), how do I accomplish this?
If you have a specific college name, let's suppose it as college
then validation is pretty easy. Following regex does that.
Regex: [\w0-9\.-]*@college\.edu
Explanation:
[\w0-9\.-]*
matches the first part of the email
which might contain Latin alphanumeric characters, dot, underscore. -
hyphen should be added either at beginning or end of character class.
@college\.edu
checks for the specific college's domain name.