How to disable or hide some field while creating a new item in list.
It should be only editable while click on edit item.
-
By looking at the image, I suppose you are using classic experience. Do you use content editor or script editor on your site? – Ganesh Sanap Jan 15 '20 at 8:44
-
Trying to use script editor. Or please let me know if any other way to solve this issue. – Ashanta Palei Jan 15 '20 at 8:45
-
What is the type of your field? – Ganesh Sanap Jan 15 '20 at 9:27
-
it is choice & multiline field Ganesh – Ashanta Palei Jan 15 '20 at 9:35
You can use SPUtility.js to hide or make ready only field in SharePoint new/edit form.
- Download SPUtility.js.
- Upload the downloaded file (SPUtility.js) to an appropriate place in SharePoint Site like ‘Style Library’
- 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.
-
Karthik, it seems not working, Can you please help me on some other way. – Ashanta Palei Jan 15 '20 at 9:15
-
-
-
-
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>
-
-
-
Welcome. Please Upvote and accept it as an answer if it helped you. – Ganesh Sanap 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. – Ashanta Palei 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? – Ganesh Sanap Jan 16 '20 at 9:43
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: