i have dropdown list , datefield. if there 1 specific value selected dropdown, datefield should required. solve that, tried use requiredif sttribute foolproof library.
but don't know how access selected value in model.
model
//this datefield [requiredif(tabstate == "discarded")] [datatype(datatype.date)] [display(name = "date discarded")] public nullable<system.datetime> datdiscarded { get; set; } //this dropdown public virtual tabstate tabstate { get; set; }
tabstate in controller
viewbag.intideastateid = new selectlist(db.tabstate, "intstateid", "strstate");
dropdown in view
<div class="form-group"> @html.labelfor(model => model.intideastateid, "state", htmlattributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @html.dropdownlist("intideastateid", null, htmlattributes: new { @class = "form-control" }) @html.validationmessagefor(model => model.intideastateid, "", new { @class = "text-danger" }) </div> </div>
how can check if selected value dropdown "discarded"?
thanks help.
Comments
Post a Comment