Validating a property if another property has a value on MVC 3/jQuery Validator

前端 未结 3 1376
心在旅途
心在旅途 2021-01-06 03:11

how can I use a Required Validation in a property Prop2 only if the Prop1 is true?

Ex:
public bool Prop1 { get; set; }

[Required] // I need this validation          


        
3条回答
  •  醉梦人生
    2021-01-06 04:02

    You can write a custom validator do to this job.

    Let me know if you need help to do it.

提交回复
热议问题