$("#my-form").find("input[type=file]").each(function(index, field){ const file = field.files[0]; if(file.size > 5242880 || file.fileSize > 5242880) { errorMessage = 'Files must be less than 5MB.'; } });