How to Make SharePoint List Column (Form Field) Read Only?
How to make a column read only in SharePoint 2010? Well, There are many ways. Here are some:
But the problem is: As soon as you set "ReadOnlyField" to true, field will be hidden from all list forms and list settings. Instead, make the "ShowInNewForm" and "ShowInEditForm" Properties to False to hide them from NewForm.aspx and EditForm.aspx but still make it visible on list settings and DispForm.aspx.
Alternatively, you can create a Field with ReadOnly Property and add the field wherever required.
However, these methods not satisfying our requirement. What we want is the field to be present in all SharePoint list forms with "Read-only" mode! So, lets see help from jQuery solution.
To disable a Choice field (Drop Down) use:
To Disable Multiline Plain text fields
Years back, there was a similar requirement for SharePoint 2007 and I used JavaScript: Make Read-Only fields in SharePoint List Forms using Javascript
- Make column read only in SharePoint list programmatically
- use jQuery to make SharePoint field read only
- Using SharePoint designer to set field read only in list forms.
Programmatically Set SharePoint list field to Read-Only using C# object model code or PowerShell script:
To make a SharePoint field read-only, We can set the " ReadOnlyField" property of SPField to "True" using either PowerShell script or C# code. Here is how:Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Get the Web $web = Get-SPWeb "http://sharepoint.crescent.com/sites/pmo" #Get the List $List = $Web.Lists["Project Metrics"] #Get the Field $Field = $List.Fields["Project ID"] #Set the field to Read only $Field.ReadOnlyField = $true $Field.Update()See the detailed implementation at: Hide Columns in SharePoint List NewForm, EditForm and DispForms.
But the problem is: As soon as you set "ReadOnlyField" to true, field will be hidden from all list forms and list settings. Instead, make the "ShowInNewForm" and "ShowInEditForm" Properties to False to hide them from NewForm.aspx and EditForm.aspx but still make it visible on list settings and DispForm.aspx.
Alternatively, you can create a Field with ReadOnly Property and add the field wherever required.
$SPSite = Get-SPSite "http://sharepoint.crescent.com" $SPWeb = $SPSite.RootWeb $SPcolumn = '<Field Type="Number" DisplayName="Project ID" Required="FALSE" ReadOnly="TRUE" ShowInDisplayForm="TRUE"ShowInViewForms="TRUE" EnforceUniqueValues="FALSE" Indexed="FALSE" Min="1" Max="10000" Group="Crescent PMO Site Columns" ID="{b81c7da6-1317-46fa-a32b-9f446c30b6e9}" StaticName="ProjectID" Name="ProjectID"></Field>' $SPWeb.Fields.AddFieldAsXml($SPcolumn)See more at: Create Site Column Feature for SharePoint 2010
However, these methods not satisfying our requirement. What we want is the field to be present in all SharePoint list forms with "Read-only" mode! So, lets see help from jQuery solution.
Make a SharePoint List form field read only with jQuery
To make a column read only, Place the below code in a text file, upload to any SharePoint library, Add a CEWP to the "NewForm.Aspx" and/or "EditForm.aspx" or wherever required. Specify this script as "Content Link" from content editor web part properties pane.<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { //Set the Field to Read only and change its background colour $("input[title='Metrics ID']").attr("readonly","true").css('background-color','#F6F6F6'); //You can disable the field also: $("input[Title='Metrics ID']").attr("disabled", "disabled"); }); </script>Output goes like this: SharePoint 2010 read only field in edit form
To disable a Choice field (Drop Down) use:
$("Select[Title='Department']").attr("disabled", "disabled");
To Disable Multiline Plain text fields
$("input[Title='Description']").attr("disabled", "disabled");
How to make a field read only in SharePoint Designer:
To make a SharePoint list column read only in EditForm.aspx, follow these steps:- Open the SharePoint site in SharePoint Designer
- Navigate to the List. Under the "Forms" section, click on "New"
- Create a new EditForm by giving it a name, and choosing other properties in the below screen.
- Edit the newly created Edit form in SharePoint designer, Click on the target property to select
- Change the "DisplayMode" property from "Edit" to "Display" in the properties pane.
- Save and close.
Years back, there was a similar requirement for SharePoint 2007 and I used JavaScript: Make Read-Only fields in SharePoint List Forms using Javascript
How to Make SharePoint List Column (Form Field) Read Only?
Reviewed by Salaudeen Rajack
on
July 10, 2013
Rating:

Hello,
ReplyDeletei used the jquery solution and it worked fine. How must be the code if i wanna set more than one column as read only?
Hope you can help me
Thanks in advance
Tj
Hi,
ReplyDeletethat's a great solution. Is it possible to make look-up columns and people picker as read only. This are the only types of columns where the code doesn't work.
Thx for your help
Use the code in my another article: Disable People Picker, Lookup Fields in SharePoint List Forms
DeleteI used your SharePoint Designer solution and it worked perfectly. THANK YOU!
ReplyDeleteUsing Jquery it works..but its still possible to alter the text by enabling the field from read only to editable using developer toolbar and then the field value can be changed. Do you have any idea how to prevent it?
ReplyDeleteTrue Sager,
DeletejQuery/JavaScript methods are weak! Use either PowerShell/C# methods to set field Properties to read-only.
I need to disable a text box based on the dropdown selected. Can u help me in this??
ReplyDeleteSure! This should help you: Disable List Form Field based on Dropdown Selection
DeleteUsed the designer solutions, works great! Thanks for this post!
ReplyDeleteRegards, Ralph Boccalini
This script is not working on the Datasheet view, could you please modify the script duly to accommodate that as well?
ReplyDeleteThanks in advance
Is it possible to make the field read only after first entry using jquery?
ReplyDeleteThanks
Hello, I also need to do the above. I want a specific field to be editable at first and then mark the field as read only. Would really appreciate the help!
DeleteThank you for this solution. The above code works great when it is a single line but fails when it is multiline text column. Can you please advise. NK
ReplyDeleteHow can I read value of Manage Editable Field properties in Javascript and do according to value of that.
ReplyDeleteThanx.
I cannot get the jquery to work. I did the directions above. Any ideas why? I added as a content editor webpart above the list web part
ReplyDeleteHi,
ReplyDeleteHow can I set column level permissions ? For instance, certain columns hidden to some users or read only but open for edit for some folks.
Good Day,
ReplyDeleteThe jQuery code isn't working for some reason, I even insert a column with the name Metrics ID to test it. Can you help me? The name of the column I want as read only is 'Country'. Is there a limit as to the amount of columns that can be made read-only as well?
Thanks
The code you provided doesn't work for my Choice input. I've tried this before and it didn't work. However, other approaches for selection have worked using jQuery. I just want to say I like your thorough explanation and screenshots, it makes everything very clear.
ReplyDeleteIs it possible to modify the field properties directly from SharePoint site settings or SharePoint Designer without touching the Form ?
ReplyDeletehi ,
ReplyDeleteif any possible way to Disable Multi line Rich text fields using java script(like above )
Regards,
If you need a non-code solution: If I want to make "Country" read-only, I add a field "CountryReadOnly". Type: Calculated field. Value: Country field. Then I hide the field Country in the content type. Deny users the right to create views.
ReplyDeleteThis is in SharePoint designer 2010, how do we do it in SharePoint designer 2013
ReplyDeleteThanks! It helped. You saved me from my boss.
ReplyDeleteHi anil: I tried this script. But it didnt work for me. Can you let me know that how did you do it? thanks
Delete