How can I validate an array of file input
with jquery.validate
plugin?
The code works fine with single file, but not with multiple upload, where name=""
is an array.
jQ:
<script type="text/javascript">
$(document).ready(function(){
$("#Main").validate({
rules: {
pic: { required:true, accept: "jpg|jpeg" }
}}
);
});
</script>
Single upload:
<html>
<head>
</head>
<body>
...
<td>Fotografija 1:</td>
<td> <input type="file" class="fup" name="pic" /> </td>
...
</body>
</html>
Multiple upload
<html>
<head>
</head>
<body>
...
<td>Fotografija 1:</td>
<td> <input type="file" class="fup" name="pic[]" /> </td>
</tr>
<tr>
<td>Fotografija 2:</td>
<td> <input type="file" class="fup" name="pic[]" /> </td>
</tr>
<tr>
<td>Fotografija 3:</td>
<td> <input type="file" class="fup" name="pic[]" /> </td>
...
</body>
</html>