Email Regular Expression MVC C#
MVC Email Regular Expression C#
Validate email address in C# .NET with Regular Expressionsusing System.ComponentModel.DataAnnotations set email address validation expression
- Valid: [email protected]
- Valid: [email protected]
- Valid: [email protected]
- Valid: [email protected]
- Invalid: [email protected]
- Invalid: [email protected]
- InValid: js#[email protected]
- InValid: j_8@[192.168.118.1]
- Invalid: [email protected]
- Invalid: js*@example.com
- Invalid: [email protected]
- Invalid: [email protected]
[RegularExpression(@"^([0-9a-zA-Z]([\+\-_\.][0-9a-zA-Z]+)*)+@(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]*\.)+[a-zA-Z0-9]{2,3})$", ErrorMessage = "Your email address is not in a valid format. Example of correct format: [email protected]")]
[RegularExpression(@"^([0-9a-zA-Z]([\+\-_\.][0-9a-zA-Z]+)*)+@(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]*\.)+[a-zA-Z0-9]{2,3})$", ErrorMessage = "Your email address is not in a valid format. Example of correct format: [email protected]")] [DataType(DataType.EmailAddress)] public string EmailAddress{ get; set; }
Email Regular Expression MVC C#
Reviewed by Bhaumik Patel
on
8:31 PM
Rating: