Custom Regular Expression not validating on the client side

前端 未结 1 1733
野性不改
野性不改 2020-12-20 09:51

I have build a custom attribute to validate on the client side a positive decimal value. The problem is that when I apply the regular expression directly to the property, it

1条回答
  •  星月不相逢
    2020-12-20 10:36

    You need to register your attribute in global.asax. In its Application_Start() method, add the following code:

    DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(PositiveDecimalAtt‌​ribute), typeof(RegularExpressionAttributeAdapter));
    

    0 讨论(0)
提交回复
热议问题