PreSaveItem() in SharePoint 2013 NewForm.aspx form

In this post we will discuss how to use PreSaveItem() in SharePoint 2013 list forms like NewForm.aspx and EditForm.aspx. Previously we have discussed how to use PreSaveAction() in this article. This works almost in same manner.

You may like to read:
Remove User by LoginName from SharePoint 2013 Group using Rest API and Remove User by Id from SharePoint group using Rest API

SharePoint deveopment training course

Follow or Unfollow people by using the SharePoint 2013 client object model

What happens when you press F5 in Visual Studio in SharePoint 2013?

Here I am trying to do some validation check before submitting an item. In the NewForm.aspx or in the EditForm.aspx, you can put the below code inside a script editor webpart.

<script type=”text/javascript”>
var j = jQuery.noConflict();
function PreSaveItem() {
var txtTitle = j(“:input[title=’Title’]”).val();
alert(txtTitle);
if(txtTitle == ”){
alert(“Please enter a title”);
return false;
}
else{
return true;
}
}
</script>

Check out Best Alternative to InfoPath -> Try Now

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →