How to Validate Attachment Field in SharePoint 2010

Hello Fellow SharePointers,

In this blog, I would like to write about a validation scenario where you need to check if your attachment field has attachments or not. In SharePoint 2010 and 2013, a custom list can have attachments. You can add attachment field using Infopath form as well. Whatever the case may be, If you want to validate the attachment field is the JavaScript to be placed either in custom form with the help of SharePoint Designer ย or you can add the scripts using content editor web part.

<script type=”text/javascript” language=”javascript”>
function PreSaveAction() {

var attach= document.getElementById(“idAttachmentsTable”);
if (attach== null || attach.rows.length == 0)

alert(“Please attach Documents in the Attachment Section.It is Mandatory”);
return false ;
else { return true ;}

Happy SharePointing ๐Ÿ™‚


Leave a Reply

Your email address will not be published. Required fields are marked *