Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.Web.Mvc;
  5.  
  6. namespace Test.Web.Attributes
  7. {
  8. [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
  9. public class DigitsAttribute : RegularExpressionAttribute, IClientValidatable
  10. {
  11. public DigitsAttribute()
  12. : base(@"^\d*$")
  13. { }
  14.  
  15. public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
  16. {
  17. yield return new ModelClientValidationRegexRule(FormatErrorMessage(metadata.GetDisplayName()), Pattern);
  18. }
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement