Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

SharePoint 2013 - save button in the ribbon - cancel saving if form not valid

$
0
0

Hi,

I want to perform some validation when a user click the save button on the SharePoint ribbon and cancel the submission of the form if it is not valid.

I am using a page layout in SharePoint 2013. The fields come from the page layout content type.

The id of the button is Ribbon.EditingTools.CPEditTab.EditAndCheckout.SaveEdit-SelectedItem

I tried without success:

- add an onclick handler on the button

var saveButton = function () {    return document.getElementById("Ribbon.EditingTools.CPEditTab.EditAndCheckout.SaveEdit-SelectedItem");
}
$(saveButton()).removeAttr("onclick");
$(saveButton()).click(    function(ev){        ev.preventDefault();        ev.returnvalue=false; // for IE only        return false;    }
);

- replace the onsubmit attribute of the form

$("form").attr("onsubmit","javascript: return false;")


Both codes are happily ignored by sp2013!



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>