0

How to disable or hide some field while creating a new item in list. It should be only editable while click on edit item. enter image description here

4
  • By looking at the image, I suppose you are using classic experience. Do you use content editor or script editor on your site? Jan 15 '20 at 8:44
  • Trying to use script editor. Or please let me know if any other way to solve this issue. Jan 15 '20 at 8:45
  • What is the type of your field? Jan 15 '20 at 9:27
  • it is choice & multiline field Ganesh Jan 15 '20 at 9:35
0

You can use SPUtility.js to hide or make ready only field in SharePoint new/edit form.

  1. Download SPUtility.js.
  2. Upload the downloaded file (SPUtility.js) to an appropriate place in SharePoint Site like ‘Style Library’
  3. Then reference the SPUtility.js in your new form.

Then use the below code:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="/Style%20Library/sputility.js"></script>
<script>
 $(document).ready(function ()
{ // Hide the filed using the display name
SPUtility.GetSPField('column display name').Hide();
// Show the field
SPUtility.GetSPField('column display name').Show();
//Make read only
SPUtility.GetSPField('column display name').MakeReadOnly();

});
</script>

For more information:

https://blog.devoworx.net/2017/03/25/show-hide-fields-based-on-a-drop-down-using-sputility-js/

You can download SPUtility.js from here:

https://archive.codeplex.com/?p=sputility

If you want to hide using CSR, kindly follow steps in the below link,

https://stackoverflow.com/questions/31736391/sharepoint-hiding-fields-in-newform-dispform-editform

Using simple jQuery.

If you want to hide the column only in new form, you can implement the following jQuery-Code:

<script type="text/javascript">
  $( document ).ready(function() {
   var strText="Column Name";
   jQuery('td nobr:contains("' + strText + '")').eq(0).closest('tr').hide();
});
</script>

JQuery-reference files need to be referred in the Code.

5
  • Karthik, it seems not working, Can you please help me on some other way. Jan 15 '20 at 9:15
  • What error you are getting?? Jan 15 '20 at 9:16
  • SPUtility.js seems harmfull & unable to download it. Jan 15 '20 at 9:18
  • Updated the answer. Jan 15 '20 at 9:31
  • Thank you karthik for your effort on this. Jan 15 '20 at 9:42
0

Try to use your code like below:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">

    $(document).ready(function(){
      //Show or hide columns  

      $('nobr:contains("Field1")').closest('tr').hide(); 
      $('nobr:contains("Field2")').closest('tr').hide();
    });

</script>
9
  • Instead of Field1 and Field2 use the name of your columns. Jan 15 '20 at 9:31
  • Thanks a lot Ganesh, It worked for me. Appreciate your support. Jan 15 '20 at 9:41
  • Welcome. Please Upvote and accept it as an answer if it helped you. Jan 15 '20 at 9:44
  • Ganesh, Code was working fine yesterday, Today i have deleted the list & created a new list, I am trying to hide the field in new form , it is working without any issue but unable to save the item. please help me on this. Jan 16 '20 at 9:33
  • Is it hiding the fields? Are you hiding any required field? Are you getting any error in browser console while saving the item? Jan 16 '20 at 9:43
0

I recommend that you hide these fields in NewForm.aspx.

You can create a new "new form" in SharePoint designer or hide fields with the powershell command.

There's a similar issue here:

Hide some fields in the NewForm.aspx for a custom list

2
  • How can i do it using powershell Jan 15 '20 at 10:12
  • Can you please suggest me if any other way apart from designer. Jan 16 '20 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.