attribute dependent on another field

后端 未结 5 1554
抹茶落季
抹茶落季 2020-11-27 04:03

In a model of my ASP.NET MVC application I would like validate a textbox as required only if a specific checkbox is checked.

Something like

public bo         


        
5条回答
  •  春和景丽
    2020-11-27 04:47

    Try my custom validation attribute:

    [ConditionalRequired("retired==true")]
    public string retirementAge {get, set};
    

    It supports multiple conditions.

提交回复
热议问题