top of page

Pre-Save Action on Document Libraries In SharePoint 2013 And Office 365

Welcome to an article on ‘Pre-Save Action on Document Libraries in SharePoint 2013 and Office 365.’ We developers face an issue when our client wants to have an action done on a document library on a save click.

Document Library uploads the document, and to validate something on the save click is tricky as the save by passes the validation and gets saved.


The solution to do any JavaScript validation is Pre Save action. So here is what you need to do.

  • Open your Document LibraryUnder the ‘Library’ tab , click on the Form Web Parts.

  • Choose Default Edit Form, you will see the screen below.

  • Click on Add a Web Part,

  • Choose Script Editor, under the Media and Content Web part.

  • Click on Edit Snippet, you will see the screen below.

  • Use the code below and click Ok.


  1. <script src="/jq-1.8.3.min.js" type="text/javascript"></script>  

  2. <script src="/jquery.SPServices-0.7.2.min.js" type="text/javascript"></script>  

  3. <script type"text/javascript">  

  4. $(document).ready(function()  {   }

  5. );  

  6. function PreSaveAction()  {  }   

  7. </script>  

a. Use the function PreSaveAction() and paste your validation under the function on the code.

b. Before saving document library the code will check your validation and will get saved.

Doesn’t it solve a lot of queries related to document libraries functions? Keep learning!

Read more articles on SharePoint:



bottom of page