Tuesday, September 30, 2014

How to make attachment mandatory in Nintex Form in SharePoint 2010

Lot of times we have requirement to make attachments to a form mandatory in a SharePoint list form. This validation is not available out of the box, although can be achieved very easily by using JQuery. Here is how.
Define the following function in a custom JavaScript file i.e. Validate.js. Include the JQuery and custom validate.js file in Nintex form in the order shown in the below screenshot.


function ValidateForm()
{
//attachment check
if($('.nf-attachmentstable tr').length < 1){
alert("Please attach a file"); 
return false;
}
}


On the submit button set the following as client function:




Here is the result.

Hope this snippet is useful to apply attachment validation in Nintex Forms. Happy coding :)

2 comments:

Anonymous said...

Does this work in current nintex version?

Manish K said...

You can check if the HTML rendered in the Attachment section on the forms is in the form of a table tag. If yes then it will work as is. If not then you might need to change the script little bit to make it work.