我有一个隐藏的输入字段类型的文件,如:
<label for="addAttachment1" class="btn btn-default">Add Attachment</label>
<input id="addAttachment1" class="hide" name="addAttachment1" type="file" />
我使用 jQuery验证库实现了文件上传的客户端验证:
$('#applicationForm').validate({
ignore: "not:hidden",
rules: {
addAttachment1: {
extension: 'jpg,png,jpeg,pdf',
filesize: true,
required: true
}
},
messages: {
addAttachment1: {
extension: 'Only images or document of pdf type are allowed.',
filesize: 'Files upto the maximum size of 25MB are allowed.',
required: 'This field is required.'
}
}
});
现在发生的事情是,只有必需的验证正在执行,而不是其他参数的验证。任何人都可以建议为什么会这样。提前谢谢!