I am trying to have the data-max value display dynamically inside of the err.push() string to show how many files that e allows.
How do I get the data-max variable to dynamically appear in the error message string?
let maxFileNum = e.target.getAttribute('data-max'); //Maximum number of files
if (fileList.files.length > maxFileNum) {
let tmpf = [];
err.push('Limit of ${maxFileNum} images allowed');
fileList.files = tmpf;
}
You will have to use back ticks (``) to represent a string literal:
let maxFileNum = e.target.getAttribute('data-max'); //Maximum number of files
if (fileList.files.length > maxFileNum) {
let tmpf = [];
err.push(`Limit of ${maxFileNum} images allowed`);
fileList.files = tmpf;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With