我想验证一个TextBox
作为必填字段,如果用户检查任何复选框。如何在mvc4中为以下代码编写javascript或jquery验证?
如何验证上述要求。是否有人可以帮忙?
以下是查看源代码片段。
<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>
后所以你有多个复选框与每个文本字段相关? –
是的,我有多个文本框与textboxes.ie组相关,对于每个组我有一个复选框 – user3301440