Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
- using System.Web.Mvc;
- namespace Test.Web.Attributes
- {
- [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
- public class DigitsAttribute : RegularExpressionAttribute, IClientValidatable
- {
- public DigitsAttribute()
- : base(@"^\d*$")
- { }
- public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
- {
- yield return new ModelClientValidationRegexRule(FormatErrorMessage(metadata.GetDisplayName()), Pattern);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement