I guess you mean Mark Altman's script..
I've tried that script and noticed there is missing one closing brace there.
as well check for case when there is not any file attached needed little extend.
finally I reverted what value is returned in what case so that it is easier to use in validation rules
try following version
function IsFileSizeExceeded(maxSizeInMB) {
var isValid=false;
for ( var i=0; i<NWF$('input[type=file]').length; i++ ) {
if(NWF$('input[type=file]')[i].files.length>0 && NWF$('input[type=file]')[i].files[0]!==null && NWF$('input[type=file]')[i].files[0]!==undefined) {
if(NWF$('input[type=file]')[i].files[0].size>(maxSizeInMB*1048600)) {
var sizeInMB = Math.round(NWF$('input[type=file]')[i].files[0].size / 10486) / 100;
isValid=true;
alert("The maximum file size is "+maxSizeInMB+"MB, but the file " + NWF$('input[type=file')[i].files[0].name + " is " + sizeInMB + "MB. Please reduce the file size before uploading.");
break;
}
}
}
return isValid;
}
I used it as follows
