Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
All-Star
21343 Points
1818 Posts
Microsoft
Oct 24, 2011 01:26 AM|LINK
Hi yenni,
You just need to add a regularexpression attribute in your model, you can do it like this:
[ExpiryDate] [RegularExpression(@"^(19|20)dd([- /.])(0[1-9]|1[012])2(0[1-9]|[12][0-9]|3[01])$”)] public DateTime ExpiryDate { get; set; }
You can change the expression to what you want.
Hope this helpful
Regards
Young Yang
Young Yang -...
All-Star
21343 Points
1818 Posts
Microsoft
Re: Custom DateTime Validation for MVC 3 unobtrusive client side validation
Oct 24, 2011 01:26 AM|LINK
Hi yenni,
You just need to add a regularexpression attribute in your model, you can do it like this:
[ExpiryDate] [RegularExpression(@"^(19|20)dd([- /.])(0[1-9]|1[012])2(0[1-9]|[12][0-9]|3[01])$”)] public DateTime ExpiryDate { get; set; }You can change the expression to what you want.
Hope this helpful
Regards
Young Yang
Feedback to us
Develop and promote your apps in Windows Store