【发布时间】:2014-04-17 18:30:35
【问题描述】:
如果用户选中任何复选框,我想验证 TextBox 作为必填字段。
我如何验证上述要求。有人可以帮忙吗?
下面是查看代码sn-p。
<div>
<div id="">
<input type="checkbox" id="partsChk" name="partsChk"/><label
class="enrollment_side">
Parts (including IRFs)
</label>
</div>
<div id="">
@Html.TextBox("PartsTitle","", new { @class = "enrollment_tbox", placeholder
= "Parts Contact Title (i.e. Parts Manager)" })
<br />
@Html.TextBox("PartsFirstName", "", new { placeholder = "First Name" })
@Html.TextBox("PartsLastName","", new { placeholder = "Last Name" })
@Html.TextBox("PartsEmpId","", new { placeholder = "BMW Employee ID" })
<br />
</div>
</div>
<div>
<div id="">
<input type="checkbox" id="salesChk" name="salesChk" /><label
class="enrollment_sidehdr">Sales – Coming in Q3 2014
</label>
</div>
<div id="">
@Html.TextBox("SalesTitle","", new { @class = "enrollment_tbox", placeholder =
"Sales Contact Title (i.e. Sales Manager)" })
<br />
@Html.TextBox("SalesFirstName", "", new { placeholder = "First Name" })
@Html.TextBox("SalesLastName","", new { placeholder = "Last Name" })
@Html.TextBox("SalesEmpId","", new { placeholder = "BMW Employee ID" })
</div>
</div>
<div>
<div id="">
<input type="checkbox" id="serviceChk" name="serviceChk" /><label
class="enrollment_sidehdr">Service – Coming in Q3 2014
</label>
</div>
<div id="">
@Html.TextBox("ServiceTitle","", new { @class = "enrollment_tbox",
placeholder = "Service Contact Title (i.e. Service Manager)" })
<br />
@Html.TextBox("ServiceFirstName", "", new { placeholder = "First Name" })
@Html.TextBox("ServiceLastName","", new { placeholder = "Last Name" })
@Html.TextBox("ServiceEmpId","", new { placeholder = "BMW Employee ID" })
<br />
</div>
</div>
【问题讨论】:
-
所以你有多个与每个文本字段相关的复选框?
-
是的,我有多个与文本框组相关的文本框。即,对于每个组,我都有一个复选框
标签: javascript jquery validation asp.net-mvc-4