Demos
Email Validation
Server Model
[EmailAddress] public string EmailAddress { get; set; }
Partial Render
<input class="form-control" type="email" value="">
Server Model
[RegularExpression("^(([^<>()\\[\\]\\.,;:\\s@\\\"]+(\\.[^<>()\\[\\]\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@(([^<>()[\\]\\.,;:\\s@\\\"]+\\.)+[^<>()[\\]\\.,;:\\s@\\\"]{2,})$", ErrorMessage = "The {0} field is not a valid e-mail address.")] public string EmailAddress { get; set; }
Partial Render
<input class="form-control" type="text" data-val-regex-pattern="^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$" value="">
The checkboxes indicate the email address will pass client validation.
The first for the EmailAddress Attribute and the second for the Regex Attribute.
Valid Email Address List
david.jones@proseware.com |
|
|
|
d.j@server1.proseware.com |
|
|
|
jones@ms1.proseware.com |
|
|
|
j@proseware.com9 |
|
|
|
js#internal@proseware.com |
|
|
|
j_9@[129.126.118.1] |
|
|
|
js@proseware.com9 |
|
|
|
j.s@server1.proseware.com |
|
|
|
"j\"s\""@proseware.com |
|
|
|
email@example.com |
|
|
|
firstname.lastname@example.com |
|
|
|
email@subdomain.example.com |
|
|
|
firstname+lastname@example.com |
|
|
|
email@123.123.123.123 |
|
|
|
email@[123.123.123.123] |
|
|
|
"email"@example.com |
|
|
|
1234567890@example.com |
|
|
|
email@example-one.com |
|
|
|
email@example.name |
|
|
|
email@example.museum |
|
|
|
email@example.co.jp |
|
|
|
firstname-lastname@example.com |
|
|
|
firstname_lastname@example.com |
|
|
|
test@test.com |
|
|
|
test@test.co.uk |
|
|
|
test+t@test.co.uk |
|
|
Valid with Unicode error in C#: "js@contoso.中国"
Strange valid email addresses which fail server validation: "_______@example.com",
"much.”more\ unusual”@example.com", "very.unusual.”@”.unusual.com@example.com",
"very.”(),:;<>[]”.VERY.”very@\\ \"very”.unusual@strange.example.com".
Invalid Email Address List
j.@server1.proseware.com |
|
|
|
j..s@proseware.com |
|
|
|
js*@proseware.com |
|
|
|
js@proseware..com |
|
|
|
plainaddress |
|
|
|
#@%^%#$@#$@#.com |
|
|
|
@example.com |
|
|
|
Joe Smith <email@example.com> |
|
|
|
email.example.com |
|
|
|
email @example@example.com |
|
|
|
.email@example.com |
|
|
|
email.@example.com |
|
|
|
email..email@example.com |
|
|
|
email@example.com(Joe Smith) |
|
|
|
email @example |
|
|
|
email@-example.com |
|
|
|
email @example.web |
|
|
|
email@example..com |
|
|
|
Abc..123@example.com |
|
|
|
test |
|
|
|
test.com |
|
|
|
test@test |
|
|
|
test@test. |
|
|
|
.something@example.com |
|
|
|
something.@example.com |
|
|
|
somebody..something@example.com |
|
|
|
something@example..com |
|
|
Strange invalid email addresses which passes server validation: "email@111.222.333.44444".