[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1010
  • Last Modified:

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!
0
avdnest
Asked:
avdnest
  • 4
  • 3
1 Solution
 
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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
 
ddrudikCommented:
Did you have a question or did you resolve it?
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now