How to Make Attachments Mandatory in SharePoint List?

Requirement: In a SharePoint list, make attachment required field!

While, creating a Document library with metadata columns is one option, requirement is only to make the attachments mandatory in SharePoint list forms. To make attachment mandatory in SharePoint list we can use simple JavaScript. Add content editor or script editor web part on "NewForm.aspx" just below SharePoint list form web part, and then place the below code in it!

JavaScript to make attachments mandatory:
<script type="text/javascript" language="javascript">

function PreSaveAction() {
if (document.getElementById('idAttachmentsRow').style.display=='none' )
     alert('Attachment is Mandatory! Please attach Documents.');
     return false ;
else {  return true;  }

and here is the script in action:
sharepoint 2013 list attachment mandatory

How to Make Attachments Mandatory in SharePoint List? How to Make Attachments Mandatory in SharePoint List? Reviewed by Salaudeen Rajack on November 01, 2015 Rating: 5


  1. Hi, I've been working on this all day and can't seem to get it to function. I've uploaded this js and added a Content Editor Web Part. I can get a test js like "Hello World" to run on page load, but when I load the above js, it's still letting me save the form without an attachment. What am I missing? Thanks!

  2. I've been testing this solution all day and can't get it to function. By loading js into a CEWP, I have been able to test simple things like getting "Hello World" to display on load. But when I switch to the above js code and attempt to submit my form without an attachment, it allows me to without the error message. What might I be missing? Thanks!


Please Login and comment to get your questions answered!

Powered by Blogger.