You will need System.ComponentModel.DataAnnotations for these:
Email Address
[RegularExpression("^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$", ErrorMessage = "Improperly formatted email. Please enter a valid email.")]
Zip Code
[RegularExpression(@"(^(?!0{5})(\d{5})(?!-?0{4})(-?\d{4})?$)", ErrorMessage = "Improperly formatted zip code. It must be entered as nnnnn or nnnnn-nnnnn.")]
Other Regular Expressions
For more great RegEx Expressions, check out the RegEx Lib
You can also check out the blog post MVC - Data Annotations Extensions
Share This To :
0 comments:
Post a Comment