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);
}
}
});$("#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.';
}
});
Also in JavaScript:
- print all the nested json key value pair c#
- js convert double to int
- how to set JSON data bootstrap treeview with java
- find base url in javascript
- get current url react router
- express request path
- vuejs filter array by dates
- create element javascript with class
- angular build production
- javascript open pdf in new tab
- funcao com o botao esc do teclado javascript
- react native add link to text
- javascript remove index from array
- crypto node
- obj[key].includes is not a function
- graal.js javascript array in java
- testing a function in jest on click react
- try catch javascript
- javascript remove quotes from string
- create dynamic fields in react
- Caesars Cipher javascript
- data type angular
- js destructuring explained
- pdfjs customizing viewer.html js event handler