This SharePoint tutorial, explains how to disable or make read-only to multiline textbox and single-line textbox in SharePoint 2010/2013/2016 using jQuery. We will make this is Edit form in the SharePoint list. You can also do the same in SharePoint new list form.
You can use SharePoint Designer to make a field read-only. Here is a method to make a field read-only using Jquery and a Content Editor Web Part in the EditForm.aspx page
By default it comes like below:
If the Edit Page option is missing from the Site Actions menu, use the ToolPaneView=2 URL parameter.
Ex:
- /EditForm.aspx?ToolPaneView=2
- Add a Content Editor Web Part
- Add the following code (in this example, “Question” is the name of my field)
Below is the jQuery Code:
$(document).ready(function () {
ConvertTextboxToLable('Title’);
ConvertTextareaToLable('Description’);
});
//Convert TextArea to Lable
function ConvertTextareaToLable(colName) {
var txtHTML = $("textarea[Title='" + colName + "']").html();
var tdColumn = $("textarea[Title='" + colName + "']").closest('td’);
var tdColumnHTML = $(tdColumn).html();
$(tdColumn).html("<div style=’display:none’>'" + tdColumnHTML + "'</div>");
$(tdColumn).append(txtHTML);
}
//Convert Textbox to Lable
function ConvertTextboxToLable(colName) {
var txtHTML = $("input[type=text][Title='" + colName + "']").val ();
var tdColumn = $("input[type=text][Title='" + colName + "']").closest('td’);
var tdColumnHTML = $(tdColumn).html();
$(tdColumn).html("<div style=’display:none’>'" + tdColumnHTML + "'</div>");
$(tdColumn).append(txtHTML);
}
After this, it will appear like below:
You may like following SharePoint tutorials:
- Rating Column in a SharePoint List or Library
- Hide new item or edit this list in SharePoint 2013/2016/Online
- Show total count of items in SharePoint 2013 list
- How to use SharePoint Alert Me feature in list or library
- Create OneNote Document Library in SharePoint 2013 Online
- Delete items or files based on conditions using PowerShell in SharePoint 2013/2016
- SharePoint List Validation Example: Announcement Expiry Date Should be greater than or equal to Created Date
This tutorial, we learned how to disable multiline and single line textbox in SharePoint using jQuery.
I am Developer working on Microsoft Technologies for the past 6+years. I am very much passionate about programming and my core skills are SharePoint, ASP.NET & C#,Jquery,Javascript,REST. I am running this blog to share my experience & learning with the community I am an MCP, MCTS .NET & Sharepoint 2010, MCPD Sharepoint 2010, and MCSD HTML 5,Sharepoint 2013 Core
Solutions. I am currently working on Sharepoint 2010, MOSS 2007, Sharepoint 2013,Sharepoint 2013 App Dev, C#, ASP.NET, and SQL Server 2008.