Mhmd Mhmd - 1 year ago 114
jQuery Question

custom validation help (Mvc Foolproof )

i have a DropDownListFor

@Html.DropDownListFor(model => model.Payment)
with values

  • cash

  • money order
    and i have TextBoxFor
    @Html.TextBoxFor(model => model.PaymentType)
    , i want to make the TextBoxFor Required only if the user select money order from the DropDownListFor,i have Mvc Foolproof and i was trying to use RequiredIf

here is my ViewModel

public string PaymentType { get; set; }
public string Payment{ get; set; }

Answer Source

@Stephen Muecke

[RequiredIf("Payment", "money order")]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download