Friday, December 17, 2010

Credit Card Validator Attribute for ASP.NET MVC 3

The first thing to notice is that I have inherited from the ValidationAttribute. This takes care of most the work, allowing me to quickly and easily implement the actual validation. ValidationAttribute is just the default, you can also inherit from other classes within the System.ComponentModel.DataAnnotations namespace. The most useful of which is the RegularExpressionAttribute. Check it out, a simple currency validator:

No comments:

Post a Comment