I wish to populate message on click of save button when we are uploading documents to document library.

I need to do something with editForm.aspx page but I'm not able to reach there.

enter image description here

How can I do this using javascript?

2 Answers 2


Edit your EditForm.aspx and put the below code inside a Script editor web part.

My suggest is that you should put your code in text file & load it to Script Editor webpart

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript">
 var j = jQuery.noConflict(); 
 function PreSaveAction() { 
 var txtTitle = j(":input[title='Title']").val(); 
   if(txtTitle == ''){        
   alert("Please enter a title");          
   return false;
   return true;

Note:- This is the sample code, If your title is blank and you click on the Save button then it will show the alert.

  • Is a function named PreSaveAction the key part here?
    – Brad
    Commented Jun 3, 2016 at 18:57
  • Yes it is calling when you click on save button on any of the form before saving the content to list.
    – Hardik
    Commented Jun 3, 2016 at 19:03

First, disable the form to open in pop up window. Next, Edit the page and add content editor web part to the page referring to a .txt or javascript file.

last step is to use form presave action method to add your javascript to show an alert message.

See here, how to use PreSaveAction: https://www.enjoysharepoint.com/create-sharepoint-sub-site-using-jquery-javascript-client-object-model-in-sharepoint-2016/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.