Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get field type file js and loop

// For multiple
$("#my-form").find("input[type=file]").each(function(index, field){
  for(var i=0;i<field.files.length;i++) {
    const file = field.files[i];
    if(file.size > 5242880 || file.fileSize > 5242880) {
      errorMessage = 'Files must be less than 5MB.';
      alert(errorMessage);
    }
  }
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #field #type #file #js #loop
ADD COMMENT
Topic
Name
3+8 =