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:
Does this work in current nintex version?
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.
Post a Comment