在C#应用程序中,具有一种形式,其中包含要填充详细信息的对象列表。我想为动态生成的字段ID设置JQuery自定义验证规则。如何设置动态字段的验证?在下面的显示表单图像和代码
<table style="width:100%">
<tbody>
<tr>
<td>
<p style="text-align: center;">Receipt Date</p>
<p>
<input class="form-control" id="ListViewModel_0__ReceiptDate" name="ListViewModel[0].ReceiptDate" required="" type="date" value="01/01/0001 12:00:00 AM"> </p>
</td>
<td style="width:25%">
<p style="text-align: center;">Description</p>
<p>
<input class="form-control" id="ListViewModel_0__Description" name="ListViewModel[0].Description" placeholder="Description" required="" type="text" value=""> </p>
</td>
<td style="width:10%">
<p style="text-align: center;">Gross Amount</p>
<p>
<input class="form-control hours totalDayHours_1 decimal" data-index="0_GrossAmount" id="ListViewModel_0__GrossAmount" name="ListViewModel[0].GrossAmount" required="required" type="text" placeholder="0.00"> </p>
</td>
<td style="width:10%">
<p style="text-align: center;">Tax </p>
<p>
<input class="form-control totalDayHours_2 hours" data-index="0_Tax" id="ListViewModel_0__Tax" name="ListViewModel[0].Tax" type="text" placeholder="0.00"> </p>
</td>
<td style="width:10%">
<p style="text-align: center;">Receipt Amount</p>
<p>
<input class="form-control totalDayHours_3 hours" data-index="0_ReceiptAmount" id="ListViewModel_0__ReceiptAmount" name="ListViewModel[0].ReceiptAmount" readonly="" type="text" placeholder="0.00"> </p>
</td>
<td style="width:10%">
<p style="text-align: center;">Exchange Rate</p>
<p>
<input class="form-control totalDayHours_4 hours" data-index="0_ExRate" id="ListViewModel_0__ExRate" name="ListViewModel[0].ExRate" type="text" placeholder="1.00"> </p>
</td>
<td style="width:10%">
<p style="text-align: center;">Net Amount</p>
<p>
<input class="form-control" id="ListViewModel_0__NetAmount" name="ListViewModel[0].NetAmount" readonly="" type="text" placeholder="0.00"> </p>
</td>
<td style="width:10%"> </td>
</tr>
<tr>
<td>
<p>
<input class="form-control" id="ListViewModel_1__ReceiptDate" name="ListViewModel[1].ReceiptDate" type="date" value="01/01/0001 12:00:00 AM"> </p>
</td>
<td style="width:25%">
<p>
<input class="form-control" id="ListViewModel_1__Description" name="ListViewModel[1].Description" placeholder="Description" type="text" value=""> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control hours totalDayHours_1 decimal" data-index="1_GrossAmount" id="ListViewModel_1__GrossAmount" name="ListViewModel[1].GrossAmount" required="required" type="text" placeholder="0.00"> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control totalDayHours_2 hours" data-index="1_Tax" id="ListViewModel_1__Tax" name="ListViewModel[1].Tax" type="text" placeholder="0.00"> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control totalDayHours_3 hours" data-index="1_ReceiptAmount" id="ListViewModel_1__ReceiptAmount" name="ListViewModel[1].ReceiptAmount" readonly="" type="text" placeholder="0.00"> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control totalDayHours_4 hours" data-index="1_ExRate" id="ListViewModel_1__ExRate" name="ListViewModel[1].ExRate" type="text" placeholder="1.00"> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control" id="ListViewModel_1__NetAmount" name="ListViewModel[1].NetAmount" readonly="" type="text" placeholder="0.00"> </p>
</td>
</tr>
<tr>
<td>
<p>
<input class="form-control" id="ListViewModel_2__ReceiptDate" name="ListViewModel[2].ReceiptDate" type="date" value="01/01/0001 12:00:00 AM"> </p>
</td>
<td style="width:25%">
<p>
<input class="form-control" id="ListViewModel_2__Description" name="ListViewModel[2].Description" placeholder="Description" type="text" value=""> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control hours totalDayHours_1 decimal" data-index="2_GrossAmount" id="ListViewModel_2__GrossAmount" name="ListViewModel[2].GrossAmount" required="required" type="text" placeholder="0.00"> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control totalDayHours_2 hours" data-index="2_Tax" id="ListViewModel_2__Tax" name="ListViewModel[2].Tax" type="text" placeholder="0.00"> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control totalDayHours_3 hours" data-index="2_ReceiptAmount" id="ListViewModel_2__ReceiptAmount" name="ListViewModel[2].ReceiptAmount" readonly="" type="text" placeholder="0.00"> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control totalDayHours_4 hours" data-index="2_ExRate" id="ListViewModel_2__ExRate" name="ListViewModel[2].ExRate" type="text" placeholder="1.00"> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control" id="ListViewModel_2__NetAmount" name="ListViewModel[2].NetAmount" readonly="" type="text" placeholder="0.00"> </p>
</td>
</tr>
<tr>
<td>
<p>
<input class="form-control" id="ListViewModel_3__ReceiptDate" name="ListViewModel[3].ReceiptDate" type="date" value="01/01/0001 12:00:00 AM"> </p>
</td>
<td style="width:25%">
<p>
<input class="form-control" id="ListViewModel_3__Description" name="ListViewModel[3].Description" placeholder="Description" type="text" value=""> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control hours totalDayHours_1 decimal" data-index="3_GrossAmount" id="ListViewModel_3__GrossAmount" name="ListViewModel[3].GrossAmount" required="required" type="text" placeholder="0.00"> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control totalDayHours_2 hours" data-index="3_Tax" id="ListViewModel_3__Tax" name="ListViewModel[3].Tax" type="text" placeholder="0.00"> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control totalDayHours_3 hours" data-index="3_ReceiptAmount" id="ListViewModel_3__ReceiptAmount" name="ListViewModel[3].ReceiptAmount" readonly="" type="text" placeholder="0.00"> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control totalDayHours_4 hours" data-index="3_ExRate" id="ListViewModel_3__ExRate" name="ListViewModel[3].ExRate" type="text" placeholder="1.00"> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control" id="ListViewModel_3__NetAmount" name="ListViewModel[3].NetAmount" readonly="" type="text" placeholder="0.00"> </p>
</td>
</tr>
<tr>
<td>
<p>
<input class="form-control" id="ListViewModel_4__ReceiptDate" name="ListViewModel[4].ReceiptDate" type="date" value="01/01/0001 12:00:00 AM"> </p>
</td>
<td style="width:25%">
<p>
<input class="form-control" id="ListViewModel_4__Description" name="ListViewModel[4].Description" placeholder="Description" type="text" value=""> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control hours totalDayHours_1 decimal" data-index="4_GrossAmount" id="ListViewModel_4__GrossAmount" name="ListViewModel[4].GrossAmount" required="required" type="text" placeholder="0.00"> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control totalDayHours_2 hours" data-index="4_Tax" id="ListViewModel_4__Tax" name="ListViewModel[4].Tax" type="text" placeholder="0.00"> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control totalDayHours_3 hours" data-index="4_ReceiptAmount" id="ListViewModel_4__ReceiptAmount" name="ListViewModel[4].ReceiptAmount" readonly="" type="text" placeholder="0.00"> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control totalDayHours_4 hours" data-index="4_ExRate" id="ListViewModel_4__ExRate" name="ListViewModel[4].ExRate" type="text" placeholder="1.00"> </p>
</td>
<td style="width:10%">
<p>
<input class="form-control" id="ListViewModel_4__NetAmount" name="ListViewModel[4].NetAmount" readonly="" type="text" placeholder="0.00"> </p>
</td>
</tr>
</tbody>
</table>
每行都需要一个名为“收据日期”,“描述”和“总金额”的字段,但仅当其中任何一个已填写时才需要。表示是否填写了说明,则需要收据日期和总金额,如果填写了总金额,则还需要另外两个。我无法在JQuery中设置该自定义验证规则。请帮我设置它。