How to count selected files
pure javascript:
document.getElementById("my_id").addEventListener("change", function() {
console.log(this.files.length);
});
in case of input type file
the value is stored in array
as files
with key name
.
$('input#my_id').change(function(){
var files = $(this)[0].files;
if(files.length > 10){
alert("you can select max 10 files.");
}else{
alert("correct, you have selected less than 10 files");
}
});
fiddle example : http://jsfiddle.net/nze2B/3/