On Sharepoint 2013 I was trying to hide a field (the complete row) based on some elements into its description.
To do so we will call our file using the JSLink (see my previous post about it).
The JS file looks like that:
(function() { // do some actions as soon as the fields are shown var loadAfterForm = { Templates: { OnPostRender:function(ctx) { // hide the field/row when "[INTERNAL USE - DO NOT CHANGE]" is detected in the field's description if (ctx.ListSchema.Field[0].Description.indexOf('[INTERNAL USE - DO NOT CHANGE]') > -1) { // get the element that represents the field var elem = document.querySelector('[id^="'+ctx.ListSchema.Field[0].Name +'_'+ ctx.ListSchema.Field[0].Id+'"]'); while (elem) { elem = elem.parentNode; if (elem) { if (elem.tagName==="BODY") break; if (elem.tagName === "TD" && elem.className.indexOf("ms-formbody") > -1) { // hide the whole row elem.parentNode.style.display="none"; break; } } } } } } } SPClientTemplates.TemplateManager.RegisterTemplateOverrides(loadAfterForm); })();