SharePoint New Item Form Actions
The following post describes 3 of the many new Form Actions available in SharePoint.
Cancel:
This example shows how to return to home page after user cancels creating the item.
$(document).ready(function() {
$('input[value=Cancel]').click(function() {
window.location.replace("https://<siteurl>/sites/Site/SitePages/Home.aspx");
});
});Pre-Save:
This example shows how to show an alert and wait for OK or Cancel action.
function PreSaveAction() {
if (confirm("Proceed with saving the item?"))
return true;
else
return false;
}
Post-Save:
This example shows how to return to home page after user creates the item.
function PostSaveAction() {
window.location.replace = "https:///sites/Site/SitePages/Home.aspx";
return true;
}Do make a note that above code requires the Jquery is referenced in the page.