Answered by:
Disable the save button in list edit form ribbon

Question
-
Hi,
I want disable the save button in ribbon, or at least the entire ribbon , from the edit form of a list...how can I do this using javascript. Thanks
Friday, February 15, 2013 4:46 AM
Answers
-
Hi Hari,
To hide just the Save button on the EditForm page, you can also use Jquery code.
Add a Content Editor Web Part on the page, and add the following script in the web part:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script><script type="text/javascript"> $(document).ready(function(){ document.getElementById("Ribbon.ListForm.Edit.Commit.Publish-Large").style.display="none"; });</script>
Thanks,
Qiao Wei
TechNet Community Support- Proposed as answer by Gnanasekhar Friday, February 22, 2013 3:51 AM
- Marked as answer by Hari nvp Friday, March 1, 2013 8:30 AM
Friday, February 22, 2013 3:26 AM
All replies
-
Hi,
Please check the below article using javascript to hide ribbon control
http://blogs.msdn.com/b/sharepointdev/archive/2012/04/30/how-to-hide-the-ribbon-in-sharepoint-2010-rajeswari-mohandas.aspx
function ShowRibbon() {
$("#s4-ribbonrow").show();
$("#s4-workspace").height($(document).height() - $("#s4-ribbonrow").height() * 2);
}
function HideRibbon() {
$("#s4-ribbonrow").hide();
var newHeight = $(document).height();
if ($.browser.msie) {newHeight = newHeight - 3; }
$("#s4-workspace").height(newHeight);
}
_spBodyOnLoadFunctionNames.push("HideRibbon");
Regards,
Gnanasekhar K
- Proposed as answer by Hemendra Agrawal Friday, February 15, 2013 5:27 AM
- Marked as answer by Hemendra Agrawal Wednesday, February 20, 2013 4:57 PM
- Unmarked as answer by Hari nvp Friday, March 1, 2013 8:30 AM
Friday, February 15, 2013 5:21 AM -
Hi,
I have already tried the same,but not working. Any jquery file reference required?
Friday, February 15, 2013 6:23 AM -
Hi hari,
If you are using v4.Master than I dont think you need to add any reference. Check in your master page if the reference is present if not than you will have to add it.
Regards,
Amish Trivedi
Friday, February 15, 2013 6:27 AM -
Ya..it works after including jquery-1.6.4.min.js. Great..Thank you. And is there is anyway to disable only the save button in ribbon , instead of the entire ribbon?..Friday, February 15, 2013 6:28 AM
-
Hi Hari,
To hide just the Save button on the EditForm page, you can also use Jquery code.
Add a Content Editor Web Part on the page, and add the following script in the web part:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script><script type="text/javascript"> $(document).ready(function(){ document.getElementById("Ribbon.ListForm.Edit.Commit.Publish-Large").style.display="none"; });</script>
Thanks,
Qiao Wei
TechNet Community Support- Proposed as answer by Gnanasekhar Friday, February 22, 2013 3:51 AM
- Marked as answer by Hari nvp Friday, March 1, 2013 8:30 AM
Friday, February 22, 2013 3:26 AM -
hi
you can completely use jquery instead of document.getElementById as
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript"> $(document).ready(function(){ $("#Ribbon\\.ListForm\\.Edit\\.Commit\\.Publish-Large").prop('disabled','disabled'); });</script>
- Edited by Ishaan Puniani Wednesday, July 10, 2013 9:50 AM instead of hiding the requirement is to make it disable
Wednesday, July 10, 2013 9:48 AM -
Great Solution Ganansekhar. Bundle of thanksFriday, August 21, 2015 6:52 AM
-
You do not need to use any JS to hide the buttons you don't want.
All you have to do is edit the form in InfoPath, go to File >> Form Options >> and in Web Browser category uncheck all the buttons you do not need.
For screenshots go here:
https://praveensharepointknowledgebase.wordpress.com/2015/04/08/remove-ribbon-commands-save-save-as-close-views-for-infopath-published-forms/
It is always better to use built-in settings than to override in JS. Because the forms are auto refreshing every few seconds, you are then required to make your function a recurring one. If something in your code is wrong and you disable the wrong thing, you will not be able to stop the form in time for you to get into the ribbon. You'll need to stop all timers via JS and that's not easy for everyone... Also, you will force focus on the element you are hiding so when the form refreshes and you are editing some field and want to press a button in your form, you'll have to press x2 times, because the focus will go away from that control with every form refresh. They happen so quickly that the user doesn't notice them, and it drives them nuts.
Sunday, January 22, 2017 4:00 PM -
At risk of responding to a two year-old answer to a five year-old question, InfoPath is deprecated. Yes it still works, but doing new development in InfoPath is not recommended.
The question was about JavaScript/jQuery, so I assume they're doing more current development using HTML5/CSS/JavaScript for forms.
Thus the solution is completely accurate and current, even today.
In our case, we want to get rid of the entire Commit section of the Ribbon - basically Edit & Cancel. So our code is:
$(document).ready(function() {
document.getElementById("Ribbon.ListForm.Edit.Commit").style.display="none";
…
});
- Edited by Barry Zickuhr Wednesday, September 12, 2018 6:38 PM
Wednesday, September 12, 2018 6:25 PM