How to use PreSaveAction() in newform.aspx in SharePoint Online/2013/2016 List

This JavaScript SharePoint, We will disucss, how to use PreSaveAction() method in SharePoint list form in SharePoint 2013/2016/Online. We will see how to use PreSaveAction() in newform.aspx in SharePoint Online/2013/2016.

PreSaveAction() in SharePoint List

PreSaveAction() a JavaScript function which helps us to do something before the item will be saved. Suppose in the list form you want to do some validation check when a user clicks on the submit button then PreSaveAction() will be very much helpful. This method called before the form is submitted.

You can use PreSaveAction() in NewForm.aspx or EditForm.aspx in any SharePoint Online/2013/2016 list.

In this example, I have a SharePoint list which has a Title column which is a mandatory field. Now I am using PreSaveAction() JavaScript function to check whether Title is blank or not. If it is blank then it will display an alert message and it will not save the item. If Title is not blank then it will Save the item

Here I have using jQuery to retrieve a Title column value, but you can use SPUtility.js to retrieve the field value as well.

I have edited the NewForm.aspx and put the below code inside a Script editor web part.

<script src=""></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;

Save the page and try to add an item to the SharePoint list. If your title is blank and you click on the Save button then it will show the alert like below:

presaveaction sharepoint 2013

You may like SharePoint JavaScript tutorials:

In the same way, you can use PreSaveAction() in editform.aspx page in SharePoint Online list. Hope this article will be helpful to you, to know more about how you can use presaveaction() in SharePoint 2013/2016/Online.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.