ASP.NET MVC 2 - Multiple Regex on a property

后端 未结 3 772
小鲜肉
小鲜肉 2021-01-07 04:36

I would like to know if a way exists in asp.net mvc 2, to have multiple regular expression on a proprety. For example :

[RegularExpression(\"[^0-9]\", Error         


        
3条回答
  •  旧时难觅i
    2021-01-07 05:20

    Try this,

    [RegularExpression("[^0-9]|[^<>]{2,}", ErrorMessageResourceName = ValidationMessageResourceNames.OnlyDigits, ErrorMessageResourceType = typeof(ValidationMessages))]
    public string City { get; set; }
    

    Here '|' has been used as OR condition to match

提交回复
热议问题