Email mask for domain part of the email.

I need to be able to allow a user to fill in his/her e-mail address up to the domain part i.e. "@hotmail.com" on a webpage. The part that they filled in must also be valid e-mail characters. This means that they can only fill in their first part of their e-mail, and they can only belong to a certain domain. Is this possible? Do I use regular expressings or a mask control. And how to do it is the question!
avdnestAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ddrudikCommented:
How do you propose to check the domain if they cannot enter their domain?  How large is your "allowed domains" list?
0
avdnestAuthor Commented:
The list of domain users can be thousands. We got different databases from different clients. Clients can create their own user names which are kept in one user store. For security reasons they can only receive mails send to their own domain.
0
ddrudikCommented:
How do you propose to check the domain if they cannot enter their domain?  Do you only want to accept the "username" portion of the e-mail address and the domain will be hard-coded on the page or will you be accepting the entire e-mail address?
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

avdnestAuthor Commented:
For each database we create a super user. He fills a form in with his domain name. That is his ticket to root him to his database with his confidential company information in it. He can create users on his database and his database only. When one of his users log in, they get routed to their company database, validating the domain of the email address. The entire email address is entered as user name and that way we know where to root a user to.
0
ddrudikCommented:
You could go simple and say that all addresses will likely be in the form of something@somethingelse which would make your job easy, since RFC validation isn't your goal here.

The regex pattern of:
^(.*?)@(.*)$

Would capture both the username and domain name in groups.

If you would like those as named groups, the regex pattern of:
^(?<user>.*?)@(?<domain>.*)$

If RFC validation is your concern, a much more complex pattern is required, in which case you can check out:
http://regexlib.com/REDetails.aspx?regexp_id=711
Or search that site for any of the many such patterns already created.

Another option is to avoid using regular expressions for this and just use a simple string function to split on the @ character then test the domain against your list.
0
avdnestAuthor Commented:
This is what I eventually found on the internet to check the "personal" bit of the e-mail address.

^[-!#$%&amp;\'*+/=?^_`{|}~a-z0-9]+(.[-!#$%&amp;\'*+/=?^_`{|}~a-z0-9]+)$

I got a control where the user can only onter the first part of the mail address. I then contol it against the above mentioned regex.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ddrudikCommented:
Did you have a question or did you resolve it?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.