Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

validate the file type, size when adding an attachment to PDF

Level 2
Level 2

Hi all,

I have issues for creating a attachment button. I have validated the file type (e.g. pdf, doc, tiff, ect.) and total size is less than 9MB when adding files to PDF. When I select the attachment button to add the file, the total size is not add everytime I add the file. It is only display of each file. I cannot figure out why is coding is not working. I have spent two days to work on it but unsucessful.

I have attached the testing form. It is easy for you to follow.

I place coding in event:click under attachment button.

Here is my coding:


var oObj =;
var aTotal;
var cFiles = oObj.dataObjects;
var counter = 0;
var nTotalSize;
var nTotalKb = "83886080"  //.......... kilobytes

if(attachmentsList.length > 0)
  var oDataObj = oObj.getDataObject(cFiles.length);
  NoOfAttachments.rawValue = cFiles.length+1;
  aTotal = (cFiles.length)
  aTotal =  oDataObj.size
  FileSize.rawValue = aTotal;
var cFiles = AttachmentDescription.rawValue;
var oObj =;

//var oDataObj = oObj.getDataObject(cFiles);
var fileName = oDataObj.path;

var fileType = fileName.substring(fileName.lastIndexOf("."));

attachmentsList.rawValue = fileName;

if(fileType != ".pdf" && fileType != ".PDF" && fileType != ".JPG" &&
  fileType != ".jpg" && fileType != ".tif" && fileType != ".TIF"&&
  fileType != ".tiff" && fileType != ".TIFF"){"Incorret Document");



var oDataObj = oObj.getDataObject(counter.value);
NoOfAttachments.rawValue = 1;



Thanks for your help.


0 Replies