Usually for validation, it involves allowed file types but just want to ask how to validate file size only? Thanks.
I also noticed when setting the error message, first it's like checking if message is about file type then else it becomes error regarding file size as show below:
function getErrorMessage(sender, args) {
var fileExtention = args.get_fileName().substring(args.get_fileName().lastIndexOf('.') + 1, args.get_fileName().length);
if (args.get_fileName().lastIndexOf('.') != -1) {//this checks if the extension is correct
if (sender.get_allowedFileExtensions().indexOf(fileExtention) == -1) {
return ("This file type is not supported.");
}
else {
return ("This file exceeds the maximum allowed size of 500 KB.");
}
}
else {
return ("not correct extension.");
}
}