Reputation: 251
I wonder if some one can give me a hand on this. I need to validate email addresses that are always [email protected] where domain.com and the dot between name and surname are always the same. I will use an asp validator but I really do not know how to write the regex yet.
<asp:RegularExpressionValidator ID="validateEmail"
runat="server" ErrorMessage="Invalid email."
ControlToValidate="txtEmail"
ValidationExpression="???????????" />
Upvotes: 0
Views: 813
Reputation: 31193
^[a-zA-Z0-9_]+\.[a-zA-Z0-9_][email protected]$
would allow characters a-z, A-Z, 0-9 and underscore in first and last names and require the domain in the end. First and last names have to have at least one character.
You can change the character set depending on your requirements and not sure if you need ^ or $ in there, if the validation expression automatically assumes the whole string.
Upvotes: 1