How to simple hide fields "All Day Event" and "Recurrence" from SharePoint calendar with javascript? Here is a solution.
Open your Calendar.
In Default New form edit page, click on Add a Web Part and select the Content Editor Web part.
From Content Editor Web part, Click on Click here to add new Content.
Now select Edit Source from ribbon and add java script to HTML
Open your Calendar.
Navigate to Calendar tab->expand Form Web Parts->and click on Default New form.
In Default New form edit page, click on Add a Web Part and select the Content Editor Web part.
From Content Editor Web part, Click on Click here to add new Content.
Now select Edit Source from ribbon and add java script to HTML
<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("hideall()");
function hideall()
{
HideField("Recurrence");
HideField("All Day Event");
}
function HideField(title){
var header_h3=document.getElementsByTagName("h3") ;
for(var i = 0; i <header_h3.length; i++)
{
var el = header_h3[i];
var foundField ;
if(el.className=="ms-standardheader")
{
for(var j=0; j<el.childNodes.length; j++)
{
if(el.childNodes[j].innerHTML == title || el.childNodes[j].nodeValue == title)
{
var elRow = el.parentNode.parentNode ;
elRow.style.display = "none"; //and hide the row
foundField = true ;
break;
}
}
}
if(foundField)
break ;
}
}
</script>
Save.
That's it!
This script does nothing to my list. It doesn't hide the fields.
ReplyDeleteI am using SP2013.
Any thoughts?
I tried again in my lab environment and working fine.
DeleteCheck your language of site, if not on English change the column name "Recurrence" and "All Day Event" in the language of the site.
The script above works for on premise, for SharePoint Online you will need to change the following two lines
ReplyDeleteChange: var header_h3=document.getElementsByTagName("h3") ;
to: var header_h3=document.getElementsByTagName("span") ;
and
Change: if(el.className=="ms-standardheader")
to: if(el.className=="ms-h3 ms-standardheader")
Hope this help.
This SharePoint Online modification works for me. Many thanks!
DeleteSame for me! Thank you!
DeleteThis worked perfectly "as is" for me - Thank You!!
ReplyDeleteworks at 100%!!! :D :D
ReplyDeleteNice! Just what I was looking for
ReplyDeleteWorked perfectly! NOTE: I am not an experienced Sharepoint user nor java script writer, and I was even to figure this out. Thank you!
ReplyDelete