Model Validation / ASP.NET MVC 3 - Conditional Required Attribute

前端 未结 4 933
温柔的废话
温柔的废话 2020-12-04 16:51

I\'m having trouble with my ASP.NET MVC 3 application. I have 2 propertiesin my model whereby I only want 1 of them required in my view based on whichever one is empty. So f

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 17:41

    I know you already have a solution, but I had a similar situation, so maybe my solution will prove helpful to someone else. I implemented a custom attribute with client-side validation. Here is my blog post: http://hobbscene.com/2011/10/22/conditional-validation/

提交回复
热议问题