Hide Columns in NewForm.aspx / EditForm.aspx / DispForm.aspx

Hide SharePoint Columns in New / Edit / View Form
Open the SharePoint Designer 2010, Go to the Corresponding List/ Library.

Open the New/Edit / View Item Aspx Page in Edit In Advance Mode add the Following script



<asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server">

Now copy & paste this JavaScript code after above mentioned tag :

<script language="javascript" type="text/javascript">
_spBodyOnLoadFunctionNames.push("hideFields");
function findacontrol(FieldName) {
   var arr = document.getElementsByTagName("!");
   // get all comments
   for (var i=0;i < arr.length; i++ )
   {
      // now match the field name
      if (arr[i].innerHTML.indexOf(FieldName) > 0)
      {         return arr[i];      }
   }
}

function hideFields() {
   var control = findacontrol("Title");
   control.parentNode.parentNode.style.display="none";
   control = findacontrol("Document Link");
   control.parentNode.parentNode.style.display="none";
   control = findacontrol("PublishDate");
   control.parentNode.parentNode.style.display="none";
}
</script>

Comments

deepali said…
This worked!! but just a suggestion that if you could add in your post, where to add this script tag, then it would save time of the novice users like me.. :)

Thanks a lot...
deepali said…
Thanks!! This helped :)

But If you could add, where to add this script tag, then it would save time of the novice users like me..:)

Thanks a lot, again!!
Gaurav Goyal said…
Hi Deepali.

Just copy & paste this JavaScript code after this tag :
Rahul said…
It does not allow me to add script below or above the specified tag. This area is highlighted in yellow in the Code view in SP Designer 2010 and remains uneditable for me :(
Gaurav Goyal said…
Hi Rahul,

You must open your page in "Edit File In Advanced Mode" option.
Anonymous said…
Hi, This code worked for me only after placing it below
and not the one you have mentioned above
renuka said…
Hi..the code is not working for me. It says the object is null or not defined..
renuka said…
Hi..the code is not working for me. It says object is null of not defined.
renuka said…
Hi..the code is not working for me. It says style is null or not an object
yureimacv said…
Funciono perfecto, gracias!!!
Unknown said…
Perfect, thanks a lot.

Popular Posts

SharePoint Interview Questions and Answers

Download Infopath Form Templates

How to get current logged user information using JavaScript ?

Steps to set Form based authentication (FBA) for SharePoint 2010

SharePoint Interview Questions and Answers II

Get List Items - JavaScript

Change Language for current user with JSOM in SharePoint Online

Cross Site List Rollup Web Part for SharePoint 2010

Hide Recently Modified Items

SharePoint 2010 CSS Chart