我无法让jQuery validation plug验证文件字段。它适用于所有周围的元素,但不适用于文件。例如,我的HTML片段
<div class="form-group form-group-sm"><label class="col-md-6">I select direct deposit for disbursement of my pay. <input class="required paySelectionRadio" type="radio" id="directDeposit" value="DD" name="PaySelection" /></label><label class="col-md-2 control-label">Initials</label><div class="col-md-4"><input class="form-control input-sm" type='text' name='DirectDepositInitials' id="directDepositInitials" /></div></div>
<div class="form-group form-group-sm">
<label class="control-label col-md-2">Account Number</label><div class="col-md-4"><input type='text' class="form-control input-sm" id="accountNumber" name='PaySelectionAccountNumber' /></div>
<label class="control-label col-md-2">Routing Number</label><div class="col-md-4"><input type='text' class="form-control input-sm" id="routingNumber" name='PaySelectionRoutingNumber' /></div>
</div>
<div class="form-group form-group-sm">
<label class="control-label col-md-2">ATTACH A VOIDED CHECK</label><div class="col-md-4"><input type="file" id="voidedCheck" name="PaySelectionCheck" /></div>
<label class="control-label col-md-2">Account Type: </label><div class="col-md-4"><select class='form-control input-sm' id="accountType" name='PaySelectionAccountType'><option value="">Select..</option><option value="Checking">Checking</option><option value="Savings">Savings</option></select></div>
</div>
上面的字段,除了&#34; paySelectionRadio&#34;有条件要求。
$("#directDepositInitials").rules("add", {
required: {
depends: function (el) { return $("#directDeposit").is(":checked"); }
}
});
$("#accountType").rules("add", {
required: {
depends: function (el) { return $("#directDeposit").is(":checked"); }
},
});
$("#voidedCheck").rules("add", {
required: {
depends: function (el) { return $("#directDeposit").is(":checked"); }
}
});
$("#routingNumber").rules("add",{
required: {
depends: function (el) { return $("#directDeposit").is(":checked"); }
}
});
$("#accountNumber").rules("add", {
required: {
depends: function (el) { return $("#directDeposit").is(":checked"); }
}
});
这适用于所有其他领域,但不适用于#34; voidedCheck&#34;。好像插件甚至找不到它。例如,这是我尝试在没有正确输入的情况下提交表单时生成的脚本。
to act on those instructions or until Company or Financial Instituion cancels the direct deposit arrangement.</p>
<div class="form-group form-group-sm"><label class="col-md-6">I select direct deposit for disbursement of my pay. <input class="required paySelectionRadio valid" id="directDeposit" value="DD" name="PaySelection" type="radio"></label><label class="col-md-2 control-label">Initials</label><div class="col-md-4"><input class="form-control input-sm error" name="DirectDepositInitials" id="directDepositInitials" type="text"><label for="directDepositInitials" class="error">This field is required.</label></div></div>
<div class="form-group form-group-sm">
<label class="control-label col-md-2">Account Number</label><div class="col-md-4"><input class="form-control input-sm error" id="accountNumber" name="PaySelectionAccountNumber" type="text"><label for="accountNumber" class="error">This field is required.</label></div>
<label class="control-label col-md-2">Routing Number</label><div class="col-md-4"><input class="form-control input-sm error" id="routingNumber" name="PaySelectionRoutingNumber" type="text"><label for="routingNumber" class="error">This field is required.</label></div>
</div>
<div class="form-group form-group-sm">
<label class="control-label col-md-2">ATTACH A VOIDED CHECK</label><div class="col-md-4"><input id="voidedCheck" name="PaySelectionCheck" type="file"></div>
<label class="control-label col-md-2">Account Type: </label><div class="col-md-4"><select class="form-control input-sm error" id="accountType" name="PaySelectionAccountType"><option value="">Select..</option><option value="Checking">Checking</option><option value="Savings">Savings</option></select><label for="accountType" class="error">This field is required.</label></div>
</div>
正如您所看到的,其他字段都有&#34;错误&#34;课程适当分配。文件字段既没有错误,也没有与之关联的有效类。
问题可能是什么?
谢谢!