hello i try to find a good solution to limit number of file in file input my problem is i need too find a generic solution because html is dynmaic generation and i have multi input in same page (and i want different limit peer field) html code previwe
<input type="file" name="micker[file_upload2][]" accept=".pdf" id="fileupload2" placeholder="Upload field2 mulitple" aria-label="Upload field2 mulitple" class="inputfile required invalid" multiple="" style="margin:0" maxuploads="2" aria-required="true" required="required" aria-invalid="true">
i need to add limit function peer field like first 2 and second 10
my idea is to inspire to https://stackoverflow.com/a/15855085/2822359
adding
max-uploads = 6
to my html and upload.js
jQuery(document).ready(function ($) {
$("body").change(function () {
var numFiles = $("input",this)[0].files.length;
var maxuploads = $("input",this)[0].attr(\'data-maxuploads\').toString();
alert(numFiles);
if (numFiles > maxuploads ) {
alert(\'Your Message\');
}else {
maxuploads = maxuploads + 1;
}
});
});
});
the error
Uncaught TypeError: Cannot read property 'length' of undefined
thanks for any help