Hide row on SharePoint newform.aspx.
Requirement : Hide row on SharePoint newform.aspx
Solution :
Add content editor web-part on page and call below JavaScript functions. (You can call function in document.ready)
function HideField(title, hide) {
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] && el.childNodes[j].innerHTML) {
if (el.childNodes[j].innerHTML == title || el.childNodes[j].innerHTML.startsWith(title)) {
var elRow = el.parentNode.parentNode;
if (hide == true) {
elRow.style.display = "none"; //and hide the row
} else {
elRow.style.display = "visible"; //and show the row
}
foundField = true;
break;
}
}
}
}
if (foundField)
break;
}
}
if (typeof String.prototype.startsWith != 'function') {
// see below for better implementation!
String.prototype.startsWith = function (str) {
return this.indexOf(str) == 0;
};
}
Comments
Post a Comment