1// For multiple
2$("#my-form").find("input[type=file]").each(function(index, field){
3 for(var i=0;i<field.files.length;i++) {
4 const file = field.files[i];
5 if(file.size > 5242880 || file.fileSize > 5242880) {
6 errorMessage = 'Files must be less than 5MB.';
7 alert(errorMessage);
8 }
9 }
10});
1$("#my-form").find("input[type=file]").each(function(index, field){
2 const file = field.files[0];
3 if(file.size > 5242880 || file.fileSize > 5242880) {
4 errorMessage = 'Files must be less than 5MB.';
5 }
6});