• Custom Email Attribute在客户端不起作用原因


    原文发布时间为:2011-07-16 —— 来源于本人的百度文章 [由搬家工具导入]

    Custom Email Attribute在客户端不起作用原因,就是未实现 IClientValidatable 接口。必须实现这个接口,才可以。如下:

     

     public class EmailAttribute : RegularExpressionAttribute, IClientValidatable

        {
            public EmailAttribute()
                : base(@"^([a-zA-Z0-9_-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([a-zA-Z0-9-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})$")
            {

            }
            public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
            {
                var rule = new ModelClientValidationRegexRule(this.ErrorMessageString, base.Pattern);
                return new[] { rule };
            }
        }

    http://haacked.com/archive/2009/11/19/aspnetmvc2-custom-validation.aspx

  • 相关阅读:
    cf-779E (拆位)
    石子游戏 (SG函数)
    [POI2017] Flappy Bird (思维题)
    Alice and Bob (SG函数)
    Red is good (DP)
    CodeVS-1669 (背包问题)
    GalaxyOJ-468 (LCA)
    BZOJ-1191 (二分图匹配)
    Reinforcement Learning 笔记(4)
    Reinforcement Learning 笔记(3)
  • 原文地址:https://www.cnblogs.com/handboy/p/7182564.html
Copyright © 2020-2023  润新知