Hide a text field in a SharePoint form using jquery

If you have several SharePoint Forms, where you want to hide the input field and using SharePoint Designer to create a custom form is not an option. Here is my collection of jQuery you can insert, using the ScriptEditor webpart.

Edit the “view” of a ListItem (DispForm.aspx)

  1. Open an element on the list, thus letting you view the DispForm.aspx page
  2. Edit the page (not the content)
  3. Insert the Scripteditor webpart
  4. Insert this code in the webpart and remember to edit the “SPBookmark_CaseID” to “SPBookmark_” + whatever name your field has
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.0.min.js"></script><script type="text/javascript" language="javascript">// <![CDATA[
$(function() {
 $('a[name=SPBookmark_CaseID]').parent().parent().parent().hide();
});
// ]]></script>

Edit the “new” and “edit” of a ListItem (NewItem.aspx and EditItem.aspx)

It is the same jQuery code that goes for the new item page and the edit item page.

  1. Edit a ListElement, thus letting you view the EditForm.aspx page or
  2. Add a Listelement, thus letting you view the NewForm.aspx page
  3. Edit the page (not the content)
  4. Add the Scripteditor webpart
  5. Insert the code in the webpart and remember to edit the “CaseID” to whatever name your input field has
<script type="text/javascript" src="https://getinthesky.sharepoint.com/SiteAssets/Scripts/jquery-2.1.0.min.js"></script><script type="text/javascript" language="javascript">// <![CDATA[
$(function() {
 $('input[title=CaseID]').parent().parent().parent().hide();
});
// ]]></script>

1 thought on “Hide a text field in a SharePoint form using jquery”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.