Restrict the type of files allowed for attachments in NITRO Forms

Applies to: SharePoint online and On-premises (2013, 2016, 2019 and SE)

Description:

In NITRO Forms, files or documents can be attached to an item from the ‘Attachments’ section. One or more ‘NITRO Attachments’ columns can also be added to the NITRO forms for adding files to the item.

In this article, we have configured validation on ‘NITRO Attachments’ column to allow only specific types of files using custom validations.

For more details on ‘NITRO Attachments’ column, refer to this article: https://www.crowcanyon.help/article/682/

Detailed steps:

  1. Configure validation on ‘NITRO Attachments’ column.

Go to NITRO Forms designer for the list -> Select ‘NITRO Attachments’ column -> Configure the custom validation as shown below in the ‘Column Settings’:

Add custom validation using JavaScript as shown below. Change the message or the file extensions as needed.

Script used in above:

var colVal = objData.ColumnValue;

var valid = true;

if(colVal && colVal.length > 0) {

                var allowedExtensions = /(\.jpg|\.jpeg|\.bmp|\.gif|\.png)$/i;

                for (var i in colVal) {

                                if (!allowedExtensions.exec(colVal[i])) {

                                                valid = false;

                                                break;

                                }

                }

}

objData.Status = valid;

if(!valid) {

    objData.Message = “Invalid file type.”;

}

return objData;

Sample output:

Allowed File types in NITRO attachments column: .jpg / .jpeg / .bmp / .gif / .png

We can also configure validation for ‘Attachments’ section same as ‘NITRO Attachments’ column.

To configure validation for ‘Attachments’ section in NITRO Form, go to Crow Canyon NITRO Forms -> Select ‘Attachments’ section and configure the validation as shown below:

Rest of the configurations are same as for above NITRO Attachments column.