基于依赖条件MVC4验证控件 [英] Validation of Controls based on dependency condition MVC4

查看:76
本文介绍了基于依赖条件MVC4验证控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am unable to validate below condition:

When user selects a dropdownlist(ddlLoanType) then user needs to select another two dropdownlist(ddlyear,ddlSection) for sure before click on submit button.
but if user enters a value in the textbox(ID,Name) then it is not mandatory to select the all dropdownlists(ddlLoanType,ddlYear,ddlSection).
If user selects a dropdownlist(ddlLoanTypes) then enters a value in textbox((ID,Name)) then it is not mandatory to select other two dropdownlists(ddlYear,ddlSection).

Any help is appreciated!!

< br $>







<pre lang="c#">

@Html.DropDownListFor(model => model.LoanType, Model.LoanType, "Select", new { @class = "form-control", id = "ddlLoanType", placeholder = "Select" })

 @Html.DropDownListFor(model => model.Year, new SelectList(listItems), "Select", new { @class = "form-control", id = "ddlYear" })

 @Html.DropDownListFor(model => model.Sections, new SelectList(sectionLst), "Select", new { @class = "form-control", id = "ddlSection" })

  @Html.TextBoxFor(model => model.ID, new { @class = "form-control", placeholder = "Enter ID...", id = "ID" })

 @Html.TextBoxFor(model => model.name, new { @class = "form-control", placeholder = "Enter Name", id = "Name" })

推荐答案

这篇关于基于依赖条件MVC4验证控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆