Showing results for 
Search instead for 
Did you mean: 

Attachment Validation in Nintex Forms

Not applicable
22 24 15.6K

Validation is a crucial piece of functionality for almost any form. As a designer of a form I want to ensure that only data that meet certain criteria can be entered and, as I define my columns, SharePoint gives me some of that functionality out of the box. So… that’s great, right?

Almost. There is one critical area of data input where there is almost no straightforward way to validate that the right kind of data is being submitted: SharePoint’s attachment functionality. Aside from a central set of disallowed attachment file formats and some limitations on attachment sizes, a user really can add as many (including zero) of whatever attachment type he or she likes.

For a collaboration environment, attachments to data input are crucial and the designer of a workflow needs to have the means to ensure only the right attachments are submitted. This is also an issue of usability for the person entering the data who needs to feel confident that they have done the right thing. We know that many of our customers have often looked to plug this gap, and some have had some measure of success using custom JavaScript.

Unfortunately, custom JavaScript can be tricky to get right and difficult to maintain so we’re now addressing this issue in the core product.

An example where attachment validation is important might be a Job Application Form. Typically, a job application requires a résumé to be attached. Sounds simple. But behind this simple request are actually a couple of implications that are critical in ensuring that anyone downstream in the workflow from this submission is getting the right information:

  1. Only one résumé should be attached to any single job application. More than one attachment and the person reviewing the submission is getting more information than they asked for. If there is no résumé attached, then the application is worthless.
  2. Only certain file formats are valid as résumés (e.g. Word documents, PDFs). Other file types may not be suitable for keyword scanning and may not even be viewable by the recruiter or hiring manager.

The latest version of Nintex Forms for SharePoint includes validation for attachments baked in to the Attachment Control. A new “Validation” section in the Attachment Control settings is now available. You’ll see that it allows the designer of the form to:

  • Specify a minimum number of attachment files for the control,
  • Limit the attachment control to a maximum number of files, and
  • Define a “whitelist” of acceptable file extensions.

Validation Section.png

You’ll also see that you can define validation messages where the minimum number of files have not been submitted and where an incorrect file format is being submitted.

So how does this work in practice?

Minimum Attachments

This one is pretty clear-cut. If the user tries to submit a form without the minimum number of attachments specified, then the form will not be submitted and the user is presented with a validation message. In the example above, I have specified that at least one attachment is required and I’ve set a custom validation message of “Résumé must be attached.”

Also, where the minimum number of files is greater than zero, we treat the control as a required field and the connected label is marked with a red asterisk to denote the attachment control as “required”.

Maximum Attachments

This one is even easier. The designer of the form can leave the Maximum Attachment Setting to “Unlimited” which is the default. In the example above, however, I’ve said that I don’t want a user to submit any more than one attachment. So, what happens if they try?

At runtime, once the number of attachments has reached the maximum number specified, the “Add Attachment” button on the form becomes disabled and is grayed-out so that no more files can be attached.

This also means that a validation message is not required for the user. However, we would recommend that, where there is ambiguity, the form designer make it clear in the form that there is a maximum number of attachments allowed.

Allowed File Formats

If left blank, any file format is allowed. However, as soon as any extensions are entered into this list, then this acts as a whitelist. Nintex Forms will not allow any files with an unlisted file extension to be uploaded. In the example above, I’ve stated that only files with the extension doc, docx or pdf will be allowed.

The way validation works here is a bit different. It’s not that Nintex Forms stops the submission of the form, it actually prevents the attachment at upload time – before the user even submits the form. When the user attempts to upload a disallowed file type, then a dialog box appears with my custom validation message. The file is not even uploaded.

Attachment Dialog.png

So that’s it: our new attachment validation in action.

We really hope you like it and we’re looking forward to making validation for attachments even more flexible. In the not too distant future we hope to deliver the ability to set Validation Rules for attachments as well, offering the same sort of conditional validation to attachments as we do to our other controls. We are also, of course, planning to include this functionality in Nintex Forms for Office 365 as well. Stay tuned.

Nintex Newbie

This is great, but a key one I think is missing here is validating the actual size of the attachment. SharePoint 2013 allows up to 250MB for an attachment, but the validation if a user attaches a file higher than this limit isn't pretty. Or if you want to specify a max size for just your form, you have to do this at the farm level. The worst thing is that there doesn't seem to be a way to validate file size limits using JavaScript (correct me if I'm wrong anyone!). So that leaves us with server side code... Oh wait we can't use server side code in Nintex Forms. Herein lies our dilemma

Not applicable

Thanks Vanessa. Can you tell us more about the business scenario you have where file size validation is critical? It is certainly something we have considered but we'd like to know what sorts of cases this would be useful. For instance, if this can only be done server-side after the files have been uploaded, is this functionality still helpful?

Nintex Newbie

There's one more thing you should validate against by default: the unsupported characters like (& " : * ? <> # {} % ~ / \) and character sequences such as double dot (..). Without this check the form (like InfoPath) might save the metadata but drop the attachment and fail to start a workflow automatically.

Nintex Newbie

     ... Ask the Sun to leave the sky, it's just ...

I don't think the browser hosting a form such as Nintex Forms has any opportunity to learn about the size of selected file before you click submit. Am I wrong? Anyway, such a feature wouldn't become compatible to widely used MSIE 8, 9 browsers anytime soon.

Nintex Newbie

Yeah this is correct. In HTML 5 there is such a feature, but it will not work in older browsers..

Nintex Newbie

I just tried doing this in my Task form but there is no validation section. Is this feature linked to List forms or am I running an old version?

Not applicable

That is a great suggestion. Thanks for that.

Nintex Newbie

Hey Roman Mellenberger‌ you are probably using an old version. Have you updated recently ?

Not applicable

Please direct me to the correct forum is this is not the one.

I have a field called "Risk" with DropDown values "High, Medium and Low"

And Second field is "Schedule Start Date"

Condition is If Risk is selected as High and if Schedule Start date is less than 5 days from Today, then it should throw an error message.

Same way if Risk is selected as Medium and if Schedule Start Date is less than 2 days from Today, then it should throw an error message.

Can you please help me on how to do this using the Nintex Forms.

Not applicable

That's great, but unfortunately when i set the minimum attachments to 1 and submit the form - it's submitted.

i don't what the problem is !!

i'm using a rule for this element to be shown only when a specific item is selected from drop down list.

could you please tell me why this happens.

Thanks in advance

Automation Master
Automation Master

Is there anyway to set the minimum number by a rule? The case would be, I only require an attachment when ...

So if a checkbox is checked, then the minimum number of attachments is set to 1, or n.

Automation Master
Automation Master

I tried using a reference, but without named controls, I cannot evaluate to any form values. Only item values which don't exist yet. So references do not help without named controls it seems.

This item property will always be 0 regardless while on a new form.

And i'm trying to do this on a Mobile App as well.

Nintex Newbie

Hi Andrew,

Have you had any luck conditionally requiring attachments?

It's something that I seem to keep circling around at work...someone suggests it would be useful so I spend some time trying a few different things, only to remember after a few tries that it can't be done...and then spend more time scouring the internet trying to find a workaround...


Automation Master
Automation Master

There are ways to use references and functions in the validation rules for attachments, but as of yet we cannot add Named Controls (values of other form controls) as references. You can check if today is wednesday, then I can add attachments. But it is not completely dynamic at this moment without named controls. I have been adding comments to the UserVoice looking for this feature if you would like to also vote Ability to validate attachment controls – Customer Feedback for Nintex 

So it will depend on your requirements for the rule if it will be possible for you. It is possible, but somewhat limited without named controls addition.

Nintex Newbie

Is there a clear cut way to REQUIRE at least ONE attachment?  I'm searching all over for that one...  Thanks in advance!!

Nintex Newbie

Basically, make invalid if no attachment is loaded into the form.  Error message:  You must include an attachment with this form...

Automation Master
Automation Master

Does the example in the blog help?

Validation Section.png

Set the minimum attachments to 1 and then set the error message.

Not applicable

Has anyone come across when the validation stops working for no apparent reason.  Works fine in other forms, but not for this particular one.  It has worked in the past but has now stopped working.

Field knows it has to have at least one document attached as the attachment label has the red star next to it, but the form allows submission without an attachment.

Not applicable

Andrew Glasser​ As always, really appreciate your involvement in these threads.

I have a form with multiple attachment controls. Some are only visible if certain control values are selected. Have you ever come across a way to require at least one attachment in a control if a requirement is met? My assumption is no, since you've requested Named Controls be added to Attachment validation configuration.

I'm thrilled that the attachment control displays the files that were uploaded in specific sections--something I really thought wouldn't work. But, without the ability to make these required IF a named control is triggered, functionality is lacking.

Any thoughts on this?

Automation Master
Automation Master

You got it right Nathan. In some scenarios, without the use of Named Controls in the attachment validation you will have to use some form of external validation such as JavaScript. Which makes things much more complicated then it should be. Please vote in the user voice and thanks for showing your need for the feature. It helps when reviewing upcoming dev roadmaps.

Automation Master
Automation Master

...But you still could try to visually trick the user that it is required until we have this ability. Have the control appear when your rule is met and have the control wrapped in a red border or something prominent with a bold font REQUIRED text nearby.

Nintex Newbie

I am having this EXACT SAME problem.

I have my settings EXACTLY as I was instructed and the form STILL SUBMITTS even though there is NO ATTACHMENT!

What is the solution to this?

Nintex Newbie

A little over 2 years after this was originally posted, the html5 file api is supported by all major browsers. The method of getting files size information is supported by 96.11% of visitors in my country (Canada) as reported by (

In case it is of use to anyone, here is a javascript function I use to see if any attachments on the form are greater than a given size:

function isValid(maxSizeInMB) {
    var isValid=true;
    for ( var i=0; i<NWF$('input[type=file]').length; i++ )  {
        if(NWF$('input[type=file]').files[0]!==undefined) {
             if(NWF$('input[type=file]').files[0].size>(maxSizeInMB*1048600) {
                var sizeInMB = Math.round(NWF$('input[type=file]').files[0].size / 10486) / 100; // # MB with two decimal places
                alert("The maximum file size is "+maxSizeInMB+"MB, but the file " + NWF$('input[type=file').files[0].name + " is " + sizeInMB + "MB. Please reduce the file size before uploading.");
    return isValid;
Nintex Newbie

Hello Mark, it works fine but I have another issue. If I attach one attachment and delete it and again attach one then after saving nintex removes all attachment. Any comment please? This is happening with IE11 not with FF.