You can use the files attribute of the file input to determine how many files are in it.
$('.fileinput').change(function(){
if(this.files.length>10){
alert('Too many files');
}
//U can set value = ''; if you dont want to allow submissions
});
// Prevent submission if limit is exceeded.
$('form').submit(function(){
if(this.files.length>10){
return false;}
});
Is There a way to limit the maximum number of files that can be uploaded in a multiple-file-input-field? I don’t mean the maximum number of files uploaded in one stack by choosing from the file-explorer, but added to the input field at all.
Thanks in advance!
@PrikeshSavla Im not sure i understand the Question. I want to limit the absolute number of files uploaded, no matte rhow often the user chooses new files. so i guess the answer to your question would be yes
But you dont mind it the validation happens after the user has chosen the files right?