guyh92
guyh92

Reputation: 383

Using a regular expression to validate an email to a specific domain

Good morning,

I would like to create a regular expression to validate an email address.... I can do this part using the standard "email" template in the asp control.

But what I would like to do is validate that the email is from a certain domain. Could anyone advise how I can - for example - make sure that an email is formed as [anyname]@mydomain.com?

Thanks Guy

Upvotes: 0

Views: 109

Answers (2)

Samiey Mehdi
Samiey Mehdi

Reputation: 9414

Try this:

\w+([-+.']\w+)*@mydomain.com

Upvotes: 1

Sachin
Sachin

Reputation: 40970

So Basically you just need to validate that input string must be ended with @mydomain.com, for that you can use $ and your validation expression would something like this

^[A-Za-z0-9._%+-][email protected]$

Upvotes: 1

Related Questions